Travis build: 1187

This commit is contained in:
30secondsofcode
2018-01-11 11:53:19 +00:00
parent 646c3477e6
commit 1adec8ce3f
4 changed files with 30 additions and 2 deletions

View File

@ -99,6 +99,7 @@ average(1, 2, 3);
* [`dropRight`](#dropright)
* [`everyNth`](#everynth)
* [`filterNonUnique`](#filternonunique)
* [`findLast`](#findlast)
* [`flatten`](#flatten)
* [`forEachRight`](#foreachright)
* [`groupBy`](#groupby)
@ -799,6 +800,28 @@ filterNonUnique([1, 2, 2, 3, 4, 4, 5]); // [1,3,5]
<br>[⬆ Back to top](#table-of-contents)
### 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.
```js
const findLast = (arr, fn) => arr.filter(fn).slice(-1);
```
<details>
<summary>Examples</summary>
```js
findLast([1, 2, 3, 4], n => n % 2 === 1); // 3
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### flatten
Flattens an array up to the specified depth.
@ -5339,6 +5362,7 @@ const httpPost = (url, callback, data = null, err = console.error) => {
const newPost = {
"userId": 1,
"id": 1337,

File diff suppressed because one or more lines are too long

View File

@ -9,5 +9,5 @@ const findLast = (arr, fn) => arr.filter(fn).slice(-1);
```
```js
findLast([1, 2, 3, 4], n => n % 2 === 1) // 3
findLast([1, 2, 3, 4], n => n % 2 === 1); // 3
```

View File

@ -32,6 +32,7 @@ const httpPost = (url, callback, data = null, err = console.error) => {
const newPost = {
"userId": 1,
"id": 1337,