Update and rename Truth-check-objects.md to truthCheckCollection.md

This commit is contained in:
Angelos Chalaris
2017-12-18 13:05:21 +02:00
committed by GitHub
parent 615d220a51
commit bb32b074a9
2 changed files with 10 additions and 18 deletions

View File

@ -0,0 +1,10 @@
### truthCheckCollection
Checks if the predicate (second argument) is truthy on all elements of a collection (first argument).
Use `Array.every()` to check if each passed object has the specified property and if it returns a truthy value.
```js
truthCheckCollection = (collection, pre) => (collection.every(obj => obj[pre]));
// truthCheckCollection([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}], "sex") -> true
```