I have 1 array with multiple object and an object. How do i find and return the data matching that object. Here is an illustration of my code.
const cars = [{model:"honda", color:"black", features:[{title:"fast",speed:"100mph"}]}]
const feature = {id:1,title:"fast",speed:"100mph"}
const match = cars.filter(car => car.features.includes(feature))
This should return
{model:"honda", color:"black", features:[{title:"fast",speed:"100mph"}]}
but it does not and not sure why. Can someone help?
You can’t use
Array.includes
for this purpose as you can’t compare two objects for equality (you will only get true if they refer to the same object). Instead you could useArray.some
andArray.every
to see if anyfeatures
object has all its key/value pairs duplicated infeature
:what’s propecia – http://propechl.com/ propecia guardian singapore
term papers for sale online – http://boessay.com/ eassy writing
Aexwvc – Viagra brand sildenafil citrate 100