JSFiddle - React, Tailwind, and code Playground
JavaScript
var persons = [
{ Color: "Gold", Location: ["Down"] },
{ Color: "Silver", Location: ["Up", "Down"] },
{ Color: "Silver", Location: ["Up"] }
];
var criteria = [
{ Field: "Color", Values: "Silver" },
{ Field: "Location", Values: ["Up", "Down"] }
];
var result = persons.filter(function (person) {
return criteria.every(function (c) {
var value = person[c.Field];
if (typeof value === 'object') {
return c.Values.length==value.length &&
c.Values.every(function(v,i){return v==value[i];});
}
else
return c.Values.indexOf(value) > -1;
})
})
console.log(result)