How may I get the truthy values? I am trying to compare the values, but before i am comparing the keys. I want to exclude the keys which have falsy values.
function truthCheck(collection, pre) {
let a=[]
for(let e in collection){
if(console.log(collection[e] && collection[e][pre]==pre )){
return true;
}else{
return false;
}
}
}
truthCheck([{"name": "Pete", "onBoat": true}, {"name": "Repeat", "onBoat": true}, {"name": "FastForward", "onBoat": null}], "onBoat");