I have the following
const A = ['test 105', 'test 300']
const B = [
{ name: 'test 105', id: 1 },
{ name: 'test 300', id: 2 },
{ name: 'test 3', id: 29 },
{ name: 'test 20', id: 20 }
]
I need to check if const B.name is equal to any of the values in const A and return only the matches from const B.
So I need the final return to be
const B = [
{ name: 'test 105', id: 1 },
{ name: 'test 300', id: 2 }
]
I was able to do this with 1 element but I want to check against const A because it might have more values in the future
const filtered = parsedResponse.filter(element => element.name == 'test 105')
console.log(filtered)
Any help is appreciated Thanks