From 7c7b11c01959a64376958d299b42a9c9fede9b51 Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Fri, 11 May 2018 15:10:00 +0000 Subject: [PATCH] Travis build: 2052 --- README.md | 4 ++-- docs/array.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 20d665275..63a9f1aef 100644 --- a/README.md +++ b/README.md @@ -1232,10 +1232,10 @@ filterNonUnique([1, 2, 2, 3, 4, 4, 5]); // [1,3,5] Returns the last element for which the provided function returns a truthy value. -Use `Array.filter()` to remove elements for which `fn` returns falsey values, `Array.slice(-1)` to get the last one. +Use `Array.filter()` to remove elements for which `fn` returns falsey values, `Array.pop()` to get the last one. ```js -const findLast = (arr, fn) => arr.filter(fn).slice(-1)[0]; +const findLast = (arr, fn) => arr.filter(fn).pop(); ```
diff --git a/docs/array.html b/docs/array.html index 820a4545e..50db30768 100644 --- a/docs/array.html +++ b/docs/array.html @@ -144,7 +144,7 @@
everyNth([1, 2, 3, 4, 5, 6], 2); // [ 2, 4, 6 ]
 

filterNonUnique

Filters out the non-unique values in an array.

Use Array.filter() for an array containing only the unique values.

const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));
 
filterNonUnique([1, 2, 2, 3, 4, 4, 5]); // [1,3,5]
-

findLast

Returns the last element for which the provided function returns a truthy value.

Use Array.filter() to remove elements for which fn returns falsey values, Array.slice(-1) to get the last one.

const findLast = (arr, fn) => arr.filter(fn).slice(-1)[0];
+

findLast

Returns the last element for which the provided function returns a truthy value.

Use Array.filter() to remove elements for which fn returns falsey values, Array.pop() to get the last one.

const findLast = (arr, fn) => arr.filter(fn).pop();
 
findLast([1, 2, 3, 4], n => n % 2 === 1); // 3
 

findLastIndex

Returns the index of the last element for which the provided function returns a truthy value.

Use Array.map() to map each element to an array with its index and value. Use Array.filter() to remove elements for which fn returns falsey values, Array.slice(-1) to get the last one.

const findLastIndex = (arr, fn) =>
   arr