I have an array of available items:
const items = [{id: 1, title: Item 1}, {id: 2, title: Item 2}, {id: 3, title: Item 3}]
and an array of items that my user has purchased:
const purchasedItems = [{id: 1, title: Item 1}, {id: 2, title: Item 2}]
I want to display an array of items that are still available to them to purchase that they haven’t bought yet, i.e. just item 3 in this case. So I want an array returned with just Item 3 in it.
I have tried:
const availableItems = items.filter(
(item) => !purchasedItems.includes(item)
)
However this just returns a list of all the items again.
Think I must be missing something quite obvious, any help appreciated!