In basic Javascript lessons on IF statements, the following example is used:
function test (myCondition) {
if (myCondition) {
return "It was true";
}
return "It was false";
}
test(true); // returns "It was true"
test(false); // returns "It was false"
What is stopping “It is false” from being returned every time? That part of the function is not included as an ELSE, so wouldn’t it be run every time? Is there something that halts the function at the IF statement if the test is TRUE?