From c78d37ef918bee3246e7e6a0866be781ffa1b752 Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Thu, 2 Aug 2018 20:15:23 +0000 Subject: [PATCH] Travis build: 181 --- README.md | 3 +-- docs/array.html | 3 +-- snippets/indexOfAll.md | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 23da51e85..e87bc036f 100644 --- a/README.md +++ b/README.md @@ -1464,8 +1464,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) => - arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []); +const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []); ```
diff --git a/docs/array.html b/docs/array.html index 40a08fec8..720961e58 100644 --- a/docs/array.html +++ b/docs/array.html @@ -187,8 +187,7 @@ 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 [].

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

const indexOfAll = (arr, val) => (arr, val) =>
-  arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);
+

indexOfAll

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

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

const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);
 
indexOfAll([1, 2, 3, 1, 2, 3], 1); // [0,3]
 indexOfAll([1, 2, 3], 4); // []
 

initial

Returns all the elements of an array except the last one.

Use arr.slice(0,-1) to return all but the last element of the array.

const initial = arr => arr.slice(0, -1);
diff --git a/snippets/indexOfAll.md b/snippets/indexOfAll.md
index 9930b06b6..67ea39086 100644
--- a/snippets/indexOfAll.md
+++ b/snippets/indexOfAll.md
@@ -6,8 +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.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);
+const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);
 ```
 
 ```js