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
if(wasThatTrue){
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
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 convertswasThatTrue 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.