I'm trying to use underscore to find an object in the array which has a child with a certain condition. lets say this is my array:
"array": [
{
"user": {
"profileIcon": 913,
"id": 62019870
},
"count": 1
},
{
"user": {
"profileIcon": 770,
"id": 32558522
},
"count": 2
}
]
Now I want to only return an object that has user.id : 62019870. This is the code I have so far but it returns an empty array:
var arr = _.filter(array, function(obj) {
return _.findWhere(obj.user, {id: 62019870});
});