Basic JavaScript - Comparisons with the Logical Or Operator

Tell us what’s happening:
I can’t fully understand the double return statement here. How come the second return statement is not executed even if the first one is ? Does this mean the function is not executing anything else after the If statement if it’s true ?

Your code so far

function testLogicalOr(val) {
  // Only change code below this line

  if (val) {
    return "Outside";

  // Only change code above this line
  return "Inside";


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0

Challenge: Basic JavaScript - Comparisons with the Logical Or Operator

Link to the challenge:

Once a return is executed, the entire function ends.
(So yes, if the if statement triggers, then the return will run and end the execution of this function)

So for each function, there is only one return statement execution possible, correct ?

You can write as many returns as you want but as soon as one runs, the function ends there.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.