function truthCheck(collection, pre) {
// Is everyone being true?
var test = true;
for(var i=0; i<collection.length; i++){
if(pre in collection[i]){
if(!collection[i][pre]){
test = false;
break;
}
} else {
test = false;
break;
}
}
return test;
}
truthCheck([{"user": "Tinky-Winky", "sex": "male", "age": 0}, {"user": "Dipsy", "sex": "male", "age": 3}, {"user": "Laa-Laa", "sex": "female", "age": 5}, {"user": "Po", "sex": "female", "age": 4}], "age");
No comments:
Post a Comment