I am trying to filter the projects that only contain "isFavorite": true.
temp1 = {
"Name": "Toronto",
"Area": [
{
"Title": "Roofing",
"Details": {
"Reports": 52,
"Projects": [
{
"Name": "ITEM A",
"isFavorite": true
},
{
"Name": "ITEM B",
"isFavorite": false
},
{
"Name": "ITEM C",
"isFavorite": true
}
]
}
}
]
}
I tried using lodash filter function but the array returns everything.
_.filter(temp1, {Area: [{Projects: [{isFavorite: true}] }]});
I tried using regular javascript but still doesn't return only the projects that are "isFavorite": true
this.branchSummaries.filter(d => d.Area.some(p => p.Projects.some(f => f.isFavorite === true)));