diff --git a/snippets/differenceBy.md b/snippets/differenceBy.md index baade057b..e6861d939 100644 --- a/snippets/differenceBy.md +++ b/snippets/differenceBy.md @@ -5,7 +5,9 @@ tags: array,intermediate Returns the difference between two arrays, after applying the provided function to each array element of both. -- Create a `Set` by applying `fn` to each element in `b`, then use `Array.prototype.map()` to apply `fn` to each element in `a`, then `Array.prototype.filter()` +- Create a `Set` by applying `fn` to each element in `b`. +- Use `Array.prototype.map()` to apply `fn` to each element in `a`. +- Use `Array.prototype.filter()` in combination with `fn` on `a` to only keep values not contained in `b`, using `Set.prototype.has()`. ```js const differenceBy = (a, b, fn) => {