HELP Return Early Pattern for Functions

Tell us what’s happening:

I have looked my code over a dozen times and it seems right. It ticks off two of the six tests. I dont understand why i cannot get the other four? Any guidance and an explanation why would be greatly appreciated

Your code so far

// Setup
function abTest(a, b) {
  // Only change code below this line
  console.log ( 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);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0.

Link to the challenge:
https://www.freecodecamp.org/challenges/return-early-pattern-for-functions

I recommend you have a think about what this code is doing:

console.log ( a< 0 || b < 0) ;

I believe that it is running a test through the console on whether a or b is less than zero and if that is true it should return “undefined”

No, what console.log does is literally print to the console the value within the brackets. So in this case, you are printing the result of the condition i.e true or false. You can open up the console from the developer tools in your browser to take a look.

What you need to do is replace the console.log with something that will evaluate the condition and then run the code within the curly braces. (at the moment the code within the curly braces always runs).

Thank you so much for the explanation i will give it another crack with that in mind. I really appreciate you taking the time to explain it to me.

No problem, If you get stuck you might want to review this lesson:
https://www.freecodecamp.org/challenges/use-conditional-logic-with-if-statements