From 52f9c16e733b7002da0749986ae2f74d1af101b8 Mon Sep 17 00:00:00 2001 From: Isabelle Viktoria Maciohsek Date: Mon, 19 Oct 2020 18:52:00 +0300 Subject: [PATCH] Update differenceBy --- snippets/differenceBy.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) => {