Everything Be True (Why expected = false)

Hi All,

i am not clear why expectation here is false ?

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”) should return false.

word “age” exist as a key in each array element…

{“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}

One of the age properties is 0, which is a falsy value (it evaluates to false when coerced to boolean).

1 Like

oh i see, thanks, so that means any time “predicate” is 0 / null / undefined/""/NaN then it is considered false…

i got it now, thanks alot for quick response…