Created
November 26, 2015 04:31
-
-
Save minsooshin/77f6ade0ffe25360d973 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Everything Be True
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bonfire: Everything Be True | |
// Author: @minsooshin | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-everything-be-true | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function every(collection, pre) { | |
// Is everyone being true? | |
var falsyArr = collection.filter(function(val) { | |
return !(val[pre]); | |
}); | |
if (falsyArr.length) return false; | |
else return true; | |
} | |
every([{"user": "Tinky-Winky"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex"); | |
//=> false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment