I have a list of 'items' and each 'item' has an 'id'. I also have a list of 'ids'. I would like to filter down my list of 'items' so that each item in my list must also match any 'id' in my list of 'ids'.
I basically want to filter out all items that do not have a corresponding id in my list of ids.
This is what I was trying, I am not sure how to check each id in my list of ids in this filter function.
items = items.filter(item => item.id !== itemIds)
CodePudding user response:
items = items.filter(item => !itemIds.includes(item.id))