Question, I have objects that I want to filter to get a specific value, but the problem is I need to map also a specific key to get all the value that need for my filter.
Sample code
const arr = [{
"invitedPeopleId": [
{
"isAdmin": false,
"isActive": true,
"_id": "6127a0d12a55f41b380482c3",
}
],
"_id": "620be40739797c2064d9e26f",
"projectId": {
"_id": "620914a24d35c13d48c6be2a"
},
"taskCreatorId": {
"isAdmin": true,
"isActive": true,
"_id": "6127a0bb2a55f41b380482c0"
},
"taskName": "Create login page for user registration"
}]
const compare = '6127a0d12a55f41b380482c3';
arr.filter((x) => x.contact.map((y) => y.landline) === compare); // return empty
Thanks!
contactwas an object (not an array) withlandlineandmobileproperties your data would be easier to navigate..filter()?compareas321321(and not'321321') - OR - changelandline: 321321tolandline: '321321'. Because321321==='321321'may be false (the left-side is a number; whereas right-side is a string). Okay, the question is updated now.