Update Truth-check-objects.md
This commit is contained in:
@ -9,10 +9,7 @@ Check if the predicate (second argument) is truthy on all elements of a collecti
|
|||||||
- Also if the object is empty then it will return false
|
- Also if the object is empty then it will return false
|
||||||
|
|
||||||
```
|
```
|
||||||
function truthCheck(collection, pre) {
|
truthCheck = (collection, pre) => (collection.every(obj => obj[pre]));
|
||||||
// Is everyone being true?
|
|
||||||
return collection.every(obj => obj[pre]);
|
|
||||||
}
|
|
||||||
|
|
||||||
truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"},
|
truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"},
|
||||||
{"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
|
{"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
|
||||||
|
|||||||
Reference in New Issue
Block a user