Files
30-seconds-of-code/test/intersectionBy/intersectionBy.js
2018-08-02 13:49:33 +03:00

6 lines
153 B
JavaScript

const intersectionBy = (a, b, fn) => {
const s = new Set(b.map(x => fn(x)));
return a.filter(x => s.has(fn(x)));
};
module.exports = intersectionBy;