Hey guys,
Looking for some feedback on my solution to the “Everything Be True” algorithm.
I know the Wiki doesn’t include every solution imaginable, but the one I used to solve this lesson isnt there and it’s quite simple, so I’m just wondering if it possibly wouldn’t work for all scenarios (ie. one’s not provided by FCF to test the algorithm).
function truthCheck(collection, pre) {
for (var i=0;i<=collection.length-1;i++){
if (collection[i][pre]){
continue;
} else {
return false;
}
}
return true;
}
Does this solution seem okay?
Thanks,
Sean
edit: Updated code to simplify/remove continue statement:
function truthCheck(collection, pre) {
for (var i=0;i<=collection.length-1;i++){
if (!collection[i][pre]){
return false;
}
}
return true;
}