Tell us what’s happening:
Your code so far
// Setup
function abTest(a, b) {
// Only change code below this line
if(a||b<0){
return undefined;
}else{
return number ;
}
// 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);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/return-early-pattern-for-functions
Hi David4,
Conditional statement with two conditions should be like this:
if ( z < 1000 || x < 1000)
hope this helps! happy coding!
I think you meant to say:
if (a < 0) || (b<0) {
}
The way you were writing it a||b<0
actually always returns true because the variable a is the only thing on the left-hand-side of the or operator and as such it is evaluated first. Since it is not a boolean, it will alway be true unless it is 0 (zero is the only number that is not evaluating to true). (additional reading for you: https://developer.mozilla.org/en-US/docs/Glossary/Truthy)
This is kind of hard for me to explain to a newbie, but I hope I’ve given you enough info.
OK.I will try it. thx for your help.

1 Like