Compare all array item into JSON array object
const filterArray = ['Ford', 'Fiat'];
const showrooms = [{
"Name": "Mark Auto",
"Location": "Delhi",
"Cars": ['Ford', 'BMW', 'Fiat']
},
{
"Name": "Cardekho",
"Location": "Mumbai",
"Cars": ['Ford', 'Fiat']
},
{
"Name": "Tata Arena",
"Location": "Pune",
"Cars": ['Ford', 'BMW']
},
{
"Name": "Nexa Showroom",
"Location": "Noida",
"Cars": ['Suzuki', 'Ford', 'Tata', 'Fiat']
}
]
I write code to filter data but not working.
const result = this.showrooms.filter(c=> this.filterArray.includes(c.Cars)).map(a=>a.Name);
Desired Output
['Mark Auto', 'Cardekho', 'Nexa Showroom']
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…