From 973ee405fcfeecbad5b6ce58c47471ed5072c896 Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Tue, 4 Sep 2018 20:53:57 +0000 Subject: [PATCH] Travis build: 373 --- README.md | 2 +- docs/array.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 766363348..3adae4b9e 100644 --- a/README.md +++ b/README.md @@ -1684,7 +1684,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/docs/array.html b/docs/array.html index 59167a256..2352cab74 100644 --- a/docs/array.html +++ b/docs/array.html @@ -224,7 +224,7 @@ };
intersection([1, 2, 3], [4, 3, 2]); // [2,3]
Returns a list of elements that exist in both arrays, after applying the provided function to each array element of both.
Create a Set by applying fn to all elements in b, then use Array.filter() on a to only keep elements, which produce values contained in b when fn is applied to them.
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))); };
intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [2.1]