I need some explain about 5 + 2 =13

Tell us what’s happening: I can pass the challenge but I don’t understand why 5 + 2 = 13
Describe your issue in detail here.

  **Your code so far**

// Setup
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));
}

console.log(abTest(6,2));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36

Challenge: Return Early Pattern for Functions

Link to the challenge:

This lesson is to show you that when you reach the return statement you’d finish the execution of funtion.

if (a < 0 || b < 0){
  return undefined;
}

by the end of the return line, the execution of the rest will be terminated and this part won’t get compiled

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

PS:

  • about Match.sqrt :

The Math.sqrt() function returns the square root of a number, that is
Math.pow

  • Math.pow

The Math.pow() function returns the base to the exponent power, as in base^exponent .

Why do you think there is code that is 5 + 2 = 13? It doesn’t, and doesn’t seem to have anything to do with the code

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