Skip to content

Instantly share code, notes, and snippets.

@minsooshin
Created November 26, 2015 04:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minsooshin/77f6ade0ffe25360d973 to your computer and use it in GitHub Desktop.
Save minsooshin/77f6ade0ffe25360d973 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Everything Be True
// 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