So this is the solution (this let me pass through the challenge)
if(a < 0 || b < 0) {
return;
}
An early return stops execution of the function, but then both variables are still declared and defined with either one negative or two negative values, they’re just not being used, or am i mistaken?
3 Likes
This is the right answer.
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
abTest(2,2);
Why this code doesn’t work
function abTest(a, b) {
if ((a || b) < 0) {
return undefined;
}
but this yes ?
function abTest(a, b) {
if (a < 0 || b < 0) {
return undefined;
}
thanks for answer!
4 Likes