Question: Why not return "undefined"?

Tell us what’s happening:
Why return is more preferable than return undefined?
Aren’t they look same?

  • to have (-2, 2) or (2, -2) in this situation.

Your code so far

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


Your browser information:

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

Challenge: Return Early Pattern for Functions

Link to the challenge:

you can totally use both return and return undefined
you can’t do return "undefined" as in this case you are just returning a string

1 Like

Oh I see. Thank for yr reply again :smile:

Your code has been blurred out to avoid spoiling a full working solution for other campers who may not yet want to see a complete solution. In the future, if you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.

Thank you.

1 Like

alright. Thank for sharing the tips here.