I'm new to Javascript and I'm struggling with how to use the map, filter, find and other functions. I have two arrays of objects, and I wanted to filter the first one with the second.
const users = [
{ name: 'Anna', age: 22, gender: 'F' },
{ name: 'John', age: 25, gender: 'M' },
{ name: 'Mary', age: 27, gender: 'F' },
{ name: 'Joe', age: 30, gender: 'M' }
]
const filter = [
{ name: 'Anna' },
{ name: 'John' }
]
// Here is the expected result:
const expected_result = [
{ name: 'Anna', age: 22, gender: 'F' },
{ name: 'John', age: 25, gender: 'M' }
]
Does anyone know what is the best way to do this?