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

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

#1

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?


#2

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


#3

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