Help me pass this test
my code is getting failed for the following cases,
abTest(2, 2)should return8 abTest(2, 2) should return a number
abTest(2, 8)should return18`

  **Your code so far**
// Setup
function abTest(a, b) {
// Only change code below this line
let valueOfReturn=0;
if((a< 0 || b<0) || (a== -2 || b==2) ||(a== 2 || b==-2) ){
return undefined;
}else if((a== 0 && b==0)){
valueOfReturn = 0;

// Only change code above this line

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

  **Your browser information:**

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

Challenge: Return Early Pattern for Functions

Link to the challenge:

Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined

What is the purpose of these checks?

Why you need this variable?

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