From 272b6588b330c0143edc0170594cd487d9b13a83 Mon Sep 17 00:00:00 2001 From: Robert Mennell Date: Thu, 2 Aug 2018 12:57:02 -0700 Subject: [PATCH] indexOfAll.md returns a functions with shadow vars It returned a function that accepted the same arguments again that when run again with the same inputs would eventually result --- snippets/indexOfAll.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/indexOfAll.md b/snippets/indexOfAll.md index a4f321f4a..9930b06b6 100644 --- a/snippets/indexOfAll.md +++ b/snippets/indexOfAll.md @@ -6,7 +6,7 @@ Use `Array.reduce()` to loop over elements and store indices for matching elemen Return the array of indices. ```js -const indexOfAll = (arr, val) => (arr, val) => +const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []); ```