i have two arrays and i want to verify to synchronic both, if in both existe the same name that should be stored in the array and the others no
for example: i need all the objects with name rea.jpg
but in my array i have like this ['dsjajdsj...h2/rea.jpg']
this is the materials
[{name: 'hgb.jpg' }, { name: 'rea.jpg'}, { name: 'ca.png' }]
the file extension is always the end of the string
i want to verify if exist an object in the names's array
const names = ['h2/rea.jpg']
const materials = [{
name: 'hgb.jpg'
}, {
name: 'rea.jpg'
}, {
name: 'ca.png'
}]
const res = materials.filter(x => names.includes(x.name))
console.log('RES', res)
expected result shoud be [ {name: 'rea.jpg'}]