I have an array of objects like:
types: [
{
id: 1,
name: "Hello"
},
{
id: 2,
name: "World"
},
{
id: 3,
name: "Jon Doe"
}
]
And I also have a simple array like this:
selected_types = [1, 2]
The desired result should filter the "types" array and exclude all the ids that are present in the "selected_types" array, like below:
final_types: [
{
id: 3,
name: "Jon Doe"
}
]
I have absolutely no idea on how to achieve this, but below is my attempt:
this.types.filter(obj => {
for (let i = 0; i < this.selected_types.length; i++) {
if (obj.id !== selected_types[i]) {
final_types.push(attribute);
}
}
});