From 3c8e4ef4b9c807e0f5685c007380174d60660fd0 Mon Sep 17 00:00:00 2001 From: Siarhei Date: Tue, 4 Sep 2018 17:00:12 +0400 Subject: [PATCH] Simplify intersectionBy --- snippets/intersectionBy.md | 2 +- test/intersectionBy/intersectionBy.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/intersectionBy.md b/snippets/intersectionBy.md index 3f28a78be..95ad8ffc7 100644 --- a/snippets/intersectionBy.md +++ b/snippets/intersectionBy.md @@ -6,7 +6,7 @@ Create a `Set` by applying `fn` to all elements in `b`, then use `Array.filter() ```js const intersectionBy = (a, b, fn) => { - const s = new Set(b.map(x => fn(x))); + const s = new Set(b.map(fn)); return a.filter(x => s.has(fn(x))); }; ``` diff --git a/test/intersectionBy/intersectionBy.js b/test/intersectionBy/intersectionBy.js index 0d598f30b..0a6684fce 100644 --- a/test/intersectionBy/intersectionBy.js +++ b/test/intersectionBy/intersectionBy.js @@ -1,5 +1,5 @@ const intersectionBy = (a, b, fn) => { - const s = new Set(b.map(x => fn(x))); + const s = new Set(b.map(fn)); return a.filter(x => s.has(fn(x))); }; module.exports = intersectionBy;