Files
30-seconds-of-code/test/intersectionBy/intersectionBy.js
2018-09-04 17:00:12 +04:00

6 lines
145 B
JavaScript

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