I have this 2 arrays:
var a = [{cod: 123, brand: 'Audi', model: 'A3', price: 15000, km: 20000},
{cod: 456, brand: 'BMW', model: 320, price: 20000, km: 30000}]
var b = [{brand: 'Audi', model: 'A3', price: 100000, km: 100000}]
What I want to do is, compare both arrays, and return the object from a
that as the same brand and model as b
and only if the maximum price and km don't exceed 100000.
If the Audi on a
had a price of 120000, then it wouldn't return anything.
EDIT: Nina answer worked perfectly. But if one of the items on filter is empty it won't return anything. How can i ignore empty values and only compare the others?