Return Early Pattern for Functions - "undefined"

Return Early Pattern for Functions - "undefined"
0.0 0


Tell us what’s happening:

Your code so far

// Setup
function abTest(a, b) {
  // Only change code below this line

  if (a < 0 || b < 0) return undefined;

  // 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
**Your browser information:**

Your Browser User Agent is: ```Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36```.

**Link to the challenge:**

Just a reminder: you're not going to see the "undefined" returned in your CodeCamp output black dialog. If you open your browser console (Ctrl-Shift-J) on Chrome, for example, Cut and paste the code into the console. Then, enter. It will return undefined when either of your test values is negative.


Do you have a question?


Nope. Sorry, I thought we could share something we found helpful. I’ll make sure to stay away from that.


It’s not like it’s a bad thing to share useful tips, or sharing what cool thing you’ve just figured out, though posting the exact answer without spoiler tags is definitely frowned upon

Best of luck with the coding!