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