Working on an Angular 2 Ionic application and I'm wondering if there's a straightforward way to filter individuals by age in a specific array and then verify if any key in another object matches the name of a person in the array, returning a boolean value.
Here is an example array:
personsArr = [{
"name": "Ram",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="91e3f0fcd1f6fcf0f8fdbff2fefc">[email protected]</a>",
"age": 23
},
{
"name": "peter",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="deadb6a7bfb3eced9eb9b3bfb7b2f0bdb1b3">[email protected]</a>",
"age": 23
},
{
"name": "John",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="610b0e090f21060c00080d4f020e0c">[email protected]</a>",
"age": 33
},
{
"name": "Bob",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="55373a376667153238343c397b363a38">[email protected]</a>",
"age": 41
}
]
And here is an object:
personObj = {
"peter": "helper",
"Ram": "helper",
"Bob": "helper"
}
I want to know how to filter personsArr by age and then check for any matching key from personObj with a person's name.
I think using a loop could work, but I'm open to suggestions if there's a better approach. Any help or advice would be greatly appreciated.