Any programming fags here? I’m a little hung up on this bit of code about Booleans.
Here’s the code from the learn JavaScript video I’m watching on YouTube :
function trueOrFalse(wasThatTrue) {
if (wasThatTrue) {
return “Yes, that was true”;
}
return “No, that was false”;
}
console.log(trueOrFalse(true));
“Yes, that was true”
(The red text being the console printing to the screen)
So my question is, in JavaScript after ‘if’ is called, is the first return statement always defaulted to true and the second always as false?
I ask this because in this line:
console.log(trueOrFalse(true));
They pass along ‘true’ but I didn’t see anywhere that was defined as what was true or false.