If I have 2 arrays:
arr1: ["1","2"]
arr2: [{id: 1, color: "green"}, {id: 2, color: "yellow"}, {id: 3, color: "red"}]
And I want to obtain:
result: [{id: 1, color: "green"}, {id: 2, color: "yellow"}]
I am trying with
arr2.filter(
e => arr1.indexOf(e.id) !== -1
);
But result is empty.