Given an array of items arr
const arr = [
{type: 'phone', color: 'green', name: 'iPhone'},
{type: 'phone', color: 'gold', name: 'Samsung'},
{type: 'computer', color: 'silver', name: 'Chromebook'},
];And rules
const rules = [
{k: 'name', v: 'iPhone'},
{k: 'color', v: 'gold'},
];Filter the elements from the items array with rules from the rules array.
example output:
[
{type: 'computer', color: 'silver', name: 'Chromebook'},
]