| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 1 5 5 13 13 15 9 9 13 4 | function findWhere(xs, query) {
let props = Object.getOwnPropertyNames(query);
for (let x of xs) {
let match = true;
for (let prop of props) {
if (query[prop] !== x[prop]) {
match = false;
break;
}
}
if (match) {
return x;
}
}
}
export default findWhere;
|