Files
30-seconds-of-code/test/intersectionBy/intersectionBy.js
2018-02-04 17:38:39 +02:00

5 lines
148 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;