Hi, guys!
I was doing this challenge and after a while i’ve got this code. I’m proud with it, it looks tight and i used what i knew.
Do you find it efficient? And what can i do to make it more tight and clean?
Your code so far
function truthCheck(collection, pre) {
return collection
.map(x => x[pre])
.map(Boolean)
.every((x) => Boolean(x) === true);
}
console.log(truthCheck([{"name": "Pete", "onBoat": true}, {"name": "Repeat", "onBoat": true, "alias": "Repete"}, {"name": "FastForward", "onBoat": null}], "onBoat"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
.
Challenge: Everything Be True
Link to the challenge: