I have to find a property in array of objects by value which is a list of strings.
For example I have someting like this:
const colors ={
colors-1: [{color: 'blue'}],
colors-2: [{color: 'gray'}, {color: 'red'}],
colors-3: [{color: 'white'}]
}
And I want to get for example property colors-2
by string which is inside array value.
Something like this:
findPropertyByValue(colors, 'red')
And output:
'colors-2'
Could You show me how to achieve this?
Thank You.