I have the following Array structure:
[{…}, {…}, {…}, {…}, {…}, {…}]
One of the object inside this array can look like this:
[
{
name: 'testing',
other: 'value',
ratings: [{category : 'passives'} , {category : 'detractor'}]
},
{
name: 'testing2',
other: 'value',
ratings: [{category : 'detractor'}]
}
]
I want to select all the objects inside the array that includes a rating with the category passive.
So with the above object the return value should look like:
[
{
name: 'testing',
other: 'value',
ratings: [{category : 'passives'} , {category : 'detractor'}]
}
]
The reason is because that's the only object in the array that has a ratings with the category of passive included.
I tried something like:
const response = 'passives'
const ape = object.filter(project => {
return project.ratings.filter(item => {
return item.category === response
})
})
filtertosome.'passive'with'passives'