Code no work why? <<the question

Tell us what’s happening:

Your code so far


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

a === 0 || b == 0
return undefined

// Only change code above this line

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

abTest(2,2);

Your browser information:

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

Challenge: Return Early Pattern for Functions

Link to the challenge:

Firstly, this is not how we conditionally check something in JavaScript.
You have to use if statement, which would for example look like this:

if (a > 0) {
  return 'a is positive';
}

Secondly, this is what the description of the challenge says:

if a or b are less than 0 the function will immediately exit with a value of undefined.

At the moment you’re checking whether a or b is equal to 0, so you should probably change something here as well, good luck! :wink:

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

if (a < 0 || b < 0 ) {
  console.log ('undefined');
}
  // Only change code above this line

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

abTest(2,2);

This no work?

You almost there, however you now logging undefined to the console.

As per challenge description, the function should:

immediately exit with a value of undefined .

The function exits when you use return. So instead of logging undefined to the console, you should return this value.