From 68fbabc5e4e33737f55b47ac973a50ecf67fc863 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Tue, 18 Feb 2020 21:29:21 +0200 Subject: [PATCH] Update intersectionBy.md --- snippets/intersectionBy.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/intersectionBy.md b/snippets/intersectionBy.md index 8c7d43390..958c18b11 100644 --- a/snippets/intersectionBy.md +++ b/snippets/intersectionBy.md @@ -10,10 +10,10 @@ Create a `Set` by applying `fn` to all elements in `b`, then use `Array.prototyp ```js const intersectionBy = (a, b, fn) => { const s = new Set(b.map(fn)); - return a.filter(x => s.has(fn(x))); + return [...new Set(a)].filter(x => s.has(fn(x))); }; ``` ```js intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [2.1] -``` \ No newline at end of file +```