From 95f5aca09b5c0ce74de66f538e8fad6ac53f4dd1 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Tue, 18 Feb 2020 21:28:58 +0200 Subject: [PATCH] Update intersection.md --- snippets/intersection.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/intersection.md b/snippets/intersection.md index 76d55c677..2fc80fb09 100644 --- a/snippets/intersection.md +++ b/snippets/intersection.md @@ -10,10 +10,10 @@ Create a `Set` from `b`, then use `Array.prototype.filter()` on `a` to only keep ```js const intersection = (a, b) => { const s = new Set(b); - return a.filter(x => s.has(x)); + return [...new Set(a)].filter(x => s.has(x)); }; ``` ```js intersection([1, 2, 3], [4, 3, 2]); // [2, 3] -``` \ No newline at end of file +```