Everything Be True - corner case logic issue

Everything Be True - corner case logic issue
0.0 0

#1

I think perhaps there is a small logic issue in the suggested solutions - it doesn’t properly check boolean properties

E.g. when onBoat == false, I think this should be truthy

However, each solution basically considers any valid boolean value of ‘false’ to be not truthy.


#2

??? Not sure what you are referring to.


#3

For example:

truthCheck([{“name”: “Pete”, “onBoat”: false}, {“name”: “Repeat”, “onBoat”: false}, {“name”: “FastFoward”, “onBoat”: false}], “onBoat”)

I would expect this to return TRUE, but because onBoat is assigned the value of FALSE, it returns False. I hope I’m being clear!


#4

Yes, because the instructions say "Check if the predicate (second argument) is truthy on all elements of a collection (first argument).

The key word is all, so if all of the objects’ onBoat properties must have truthy values, then your function should return true, otherwise return false. In the example you posted above, one of the objects {“name”: “FastFoward”, “onBoat”: false} has an onBoat property with the falsy value (false), so your function should return false.


#5

Got it - I took truthy to mean that the object both has the property, and the value is valid (different from the value being false). Guess I just didn’t quite understand what the criteria for “truthy” is!


#6

If you go back to the Falsy Bouncer challenge, you learned their are only 6 falsy values. Everything else is a truthy value.


#7

Goldfish memory here! Thanks, Randell! You rock!