const test_data = [
{
_id: '111',
title: 'Book',
},
{
_id: '222',
title: 'Cat,
}
]
I have data that looks like this, and I want to use an array of titles e.g. ['Book', 'Cat']
to retrieve an array of the _id
s that match with the title.
From that sample array, I want to retrieve ['111', '222']
.
What I've tried was
test_data.filter((item) => { return item.title === "Book" })
But it only retrieves a single object that has Book
as the title.
How can I apply this using multiple string values?