Facebook | Phone screen | 2021 | Filter items by array of rules
Anonymous User
325
Jan 21, 2021
Jan 29, 2021
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'},
]Comments (3)


