Given the following array of objects:
let list = [
{id: 100, desc: 'Apple'},
{id: 555, desc: 'Banana'},
{id: 110, desc: 'Orange'},
{id: 120, desc: 'Strawberry'}
]
and the following:
let myObj = {
"res": {
"myId": 555,
"allIds": [
{
"subId": 100
},
{
"subId": 120
}
]
}
}
I need to filter the list array above so that it doesn't include the myId value and any of the subId values within the allIds array.
So based on this requirement after filtering, I expect to only see the following remaining value within the list array, i.e.:
let list = [
{id: 110, desc: 'Orange'}
]
as id: 110 doesn't equal myId and doesn't exist within the allIds array.
I tried the following which works for just myId:
let filteredArr = {list.filter((el) => el.id !== myObj.res.myId)}
but unsure how to also exclude/filter the subId's within the allIds array as well?
myObj.