Https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/return-early-pattern-for-functions/

Cant figure this out,Please i need help.

// 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(2,2);



**Link to the challenge:**
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/return-early-pattern-for-functions/

You are returning an empty string, the challenge asks you to return undefined

you aren’t returning an empty string, challenge wants you to return undefined property.

return undefined;

// Setup

function abTest(a, b) {

// Only change code below this line

if (a < 0 && b < 0){

return undefined;

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

abTest(2,2);

You don’t need return undefined twixe, one is enough

Also in this way you are returning it only if both a and b are negative, you need to return it even if only one of them is negative (why did you change this?)

1 Like

Thanks it worked