diff --git a/README.md b/README.md index b106fead2..b5e5c1f98 100644 --- a/README.md +++ b/README.md @@ -865,10 +865,10 @@ head([1, 2, 3]); // 1 ### indexOfAll -Returns all indices of `val` in an array. If `val` never occurs, returns `[-1]`. +Returns all indices of `val` in an array. If `val` never occurs, returns `[]`. Use `Array.forEach()` to loop over elements and `Array.push()` to store indices for matching elements. -Return `[-1]` if `length` of the array of indices is `0`, otherwise return the array of indices. +Return the array of indices. ```js const indexOfAll = (arr, val) => { diff --git a/docs/index.html b/docs/index.html index 710b3d69a..aa57b64ac 100644 --- a/docs/index.html +++ b/docs/index.html @@ -125,7 +125,7 @@ Object.assig groupBy(['one', 'two', 'three'], 'length'); // {3: ['one', 'two'], 5: ['three']}

Returns the head of a list.

Use arr[0] to return the first element of the passed array.

const head = arr => arr[0];
 
head([1, 2, 3]); // 1
-

indexOfAll

Returns all indices of val in an array. If val never occurs, returns [-1].

Use Array.forEach() to loop over elements and Array.push() to store indices for matching elements. Return [-1] if length of the array of indices is 0, otherwise return the array of indices.

const indexOfAll = (arr, val) => {
+

indexOfAll

Returns all indices of val in an array. If val never occurs, returns [].

Use Array.forEach() to loop over elements and Array.push() to store indices for matching elements. Return the array of indices.

const indexOfAll = (arr, val) => {
   const indices = [];
   arr.forEach((el, i) => el === val && indices.push(i));
   return indices;