Question: how on earth does the computer actually know what wasThatTrue even means? Is this just practicing if/else statements and we just assume that the computer already knows the value of wasThatTrue? This is super confusing to me.
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/86.0.4240.183 Safari/537.36.
Challenge: Use Conditional Logic with If Statements
The computer is evaluating if the parameter passed in the function wasThatTrue is true or false.
If you look at the tests after they run, you can see that they tested true and false to check the function. If anything is passed as a parameter that evaluates true, it will return “Yes, that was true.”
Thank you. However I am still confused. wasThatTrue was never defined in the code…I guess this is an example just so we can practice coding syntax for if statements?
Hi
wasThatTrue is an argument for the function and its a placeholder for any data you give when you calling it. It had defined when the whole function had defined and it might have any name like x, y or wasThatTrue.