Travis build: 2000

This commit is contained in:
30secondsofcode
2018-04-27 12:51:30 +00:00
parent f255087c29
commit d098a802a7
12 changed files with 36 additions and 11 deletions

View File

@ -156,6 +156,7 @@ average(1, 2, 3);
* [`reducedFilter`](#reducedfilter)
* [`reduceSuccessive`](#reducesuccessive)
* [`reduceWhich`](#reducewhich)
* [`reject`](#reject)
* [`remove`](#remove)
* [`sample`](#sample)
* [`sampleSize`](#samplesize)
@ -2182,6 +2183,27 @@ reduceWhich(
<br>[⬆ Back to top](#table-of-contents)
### reject
Takes a predicate and array, like `Array.filter()`, but only keeps `x` if `pred(x) === false`.
```js
const reject = (pred, array) => array.filter((...args) => !pred(...args));
```
<details>
<summary>Examples</summary>
```js
reject(x => x % 2 === 0, [1, 2, 3, 4, 5]); // [1, 3, 5]
reject(word => word.length > 4, ['Apple', 'Pear', 'Kiwi', 'Banana']); // ['Pear', 'Kiwi']
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### remove
Removes elements from an array for which the given function returns `false`.