How is "wasThatTrue" a condition?

Tell us what’s happening:

I thought conditions were more like if (x<1) or maybe if(wasThatTrue=true)?
What exactly in this code implies that “Yes, that was true” only returns if it is true?

  **Your code so far**

function trueOrFalse(wasThatTrue) {
// Only change code below this line

  return "Yes, that was true";

return "No, that was false";

// Only change code above this line

  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36.

Challenge: Use Conditional Logic with If Statements

Link to the challenge:


if(wasThatTrue === True){...} is the same as if(wasThatTrue){...}.

In this case we can use this shorthand because we know the function trueOrFalse is only going to be given a boolean value.

Let me know if you have anymore questions about this.

1 Like

Good to know, thank you very much :+1:

Ehhh, not really. It’s actually more complicated but cooler than that.

Sure the tests only use true and false as inputs, but anything can be used as an input in this function.

Right here, JavaScript converts wasThatTrue into a boolean value.

If wasThatTrue was a logical conditional, such as 5 < 1, then that will be evaluated to the correct boolean value (false in that case).

If the input is not a logical conditional when we called the function trueOrFalse(), then JavaScript converts the input based on the truthiness/falseyness of the value. It will be covered later, but basically, 0, null, undefined, NaN, "", and a few other values are converted to false while everything else is converted to true.

To see this, try


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.