I come to have two different arrays. One containing only ids as integers (coming from a searchBox) and another one containing objects, like:
categories = [1, 2, 5, 8];
items = [
{ title: 'Hello', description: 'whatever you want to be a description', categoryId: 1 },
{ title: 'Hello', description: 'whatever you want to be a description', categoryId: 3 }
]
I've been looking for a way to remove any item in the second array if its categoryId is equal to anyvalue present in the categories array.
At first I tried to splice, loop into them (and thus created some kind of infinite loop), look for indexOf... either I did it badly or used the wrong method but for three days now, nothing is doing the job.
Is there any method in JS to return a new array like items.splice(every.categories)
(well I know this one doesn't exist but who knows... anything similar in ES6 ?