diff --git a/snippets/unionBy.md b/snippets/unionBy.md index 3680c6d1c..91c9e6662 100644 --- a/snippets/unionBy.md +++ b/snippets/unionBy.md @@ -8,7 +8,7 @@ Return the last set converted to an array. ```js const unionBy = (a, b, fn) => { - const s = new Set(a.map(v => fn(v))); + const s = new Set(a.map(fn)); return Array.from(new Set([...a, ...b.filter(x => !s.has(fn(x)))])); }; ``` diff --git a/test/unionBy/unionBy.js b/test/unionBy/unionBy.js index 86d52180c..e03f9998b 100644 --- a/test/unionBy/unionBy.js +++ b/test/unionBy/unionBy.js @@ -1,5 +1,5 @@ const unionBy = (a, b, fn) => { - const s = new Set(a.map(v => fn(v))); + const s = new Set(a.map(fn)); return Array.from(new Set([...a, ...b.filter(x => !s.has(fn(x)))])); }; module.exports = unionBy;