Tell us what’s happening:
Hi friends at FCC!
I have a question about this if block. It is not a problem with the solution, but I am trying to understand how the syntax works. The if block below contains one if
block with a return statement and below it there is a return statement by itself.
When I came to the later lessons it introduced the else
keyword, which will execute some code when the if
is not true.
But in this example there is no else
used, so it looks to me if the if
condition is true
, it will run the code in the if block AND ALSO run the code at the bottom, because there is no else
there. So at first will it set the return value to “Yes, that was true”, and then overwrite it to “No, that was false”?
Please let me know if I have misunderstood this.
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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15
Challenge Information:
Basic JavaScript - Use Conditional Logic with If Statements
http://localhost:8000/learn/javascript-algorithms-and-data-structures/basic-javascript/use-conditional-logic-with-if-statements