I am trying to check if a value is present in a nested array. This is what the data I am working with looks like:
[
{
name: 'bob',
occupation: ['Teacher', 'Store Owner'],
},
{
name: 'grace',
occupation: ['Doctor'],
},
]
I am trying to see if the occupation value already exists. This is my current code:
const occupationExists = (value) => users.some((user) => user.occupation === value);
I understand that this doesn't work because it isn't accessing the values in the array but how do I go about it? Any help would be appreciated.