"return-early-pattern-for-functions" challenge let me through even though my solution is wrong

I am on the JavaScript challenge “Return Early Pattern For Functions”. Here is my code:


// Setup
function abTest(a, b) {
  // Only change code below this line
  
  if (a < 0 || b < 0) { 
      return;
  }
  
  // Only change code above this line

  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(8,2);

When I press Ctrl + Enter it says you passed but, the console returns “18” and not “undefined”. What did I do wrong?

How can I stop execution after the IF statement?

Both a and b are greater than or equal to zero so it returns the Math.round(...).

Oh, man… Thank you, Ben. I thought there are some glitches with my PC. Looks like it is me who is glitching.

1 Like