diff --git a/snippets/indexOfAll.md b/snippets/indexOfAll.md index e06f58946..b3485f3c4 100644 --- a/snippets/indexOfAll.md +++ b/snippets/indexOfAll.md @@ -9,11 +9,11 @@ Return `[-1]` if `length` of the array of indices is `0`, otherwise return the a const indexOfAll = (arr, val) => { const indices = []; arr.forEach((el, i) => el === val && indices.push(i)); - return indices.length ? indices : [-1]; + return indices; }; ``` ```js indexOfAll([1, 2, 3, 1, 2, 3], 1); // [0,3] -indexOfAll([1, 2, 3], 4); // [-1] +indexOfAll([1, 2, 3], 4); // [] ```