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), []); ```