Skip to content

Instantly share code, notes, and snippets.

Created December 11, 2015 12:14
Show Gist options
  • Save anonymous/952e5cd7f28618100230 to your computer and use it in GitHub Desktop.
Save anonymous/952e5cd7f28618100230 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/patrickcurl 's solution for Bonfire: Everything Be True
// Bonfire: Everything Be True
// Author: @patrickcurl
// 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 returnVal = true;
collection.forEach(function(x){
console.log(x.hasOwnProperty(pre));
if(!x.hasOwnProperty(pre) || !Boolean(x[pre])){
returnVal = false;
}
});
return returnVal;
}
every([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment