I am trying to remove objects from array based on value which is not matching.
This is my items array:
var items = [
{"id":"88","name":"Lets go testing"},
{"id":"99","name":"Have fun boys and girls"},
{"id":"108","name":"You are awesome!"}
];
var arr=["88","108"];
Here I am able to removing objects from array based on matching values..But I want to keep matching value objects and need to remove unmatched objects.
This is how I'm removing matching objects from array.
for(let i in arr) {
items = items.filter(function(item) {
return item.id !== arr[i];
});
}
items.filter( item => arr.includes( item.id ) )