I have two separate arrays. One array contains only integers as IDs (from a searchBox) and the other array contains objects, such as:
categories = [1, 2, 5, 8];
items = [
{ title: 'Hello', description: 'any description you want', categoryId: 1 },
{ title: 'Hello', description: 'any description you want', categoryId: 3 }
]
I've been trying to find a way to remove any item in the second array if its categoryId matches any value in the categories array.
Initially, I attempted to use splice, loop through them (which resulted in an infinite loop), tried indexOf... but after three days, nothing seems to be working.
Is there a method in JS that could return a new array like items.splice(every.categories)
(I know this syntax doesn't exist, but is there anything similar in ES6 ?