Add any, anyBy, all, allBy, none, noneBy
This commit is contained in:
13
snippets/allBy.md
Normal file
13
snippets/allBy.md
Normal file
@ -0,0 +1,13 @@
|
||||
### allBy
|
||||
|
||||
Returns `true` if the provided predicate function returns `true` for all elements in a collection, `false` otherwise.
|
||||
|
||||
Use `Array.every()` to test if all elements in the collection return `true` based on `fn`.
|
||||
|
||||
```js
|
||||
const allBy = (arr, fn) => arr.every(fn);
|
||||
```
|
||||
|
||||
```js
|
||||
allBy([4,2,3], x => x > 1); // true
|
||||
```
|
||||
Reference in New Issue
Block a user