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 +```