Freecodecamp: Undefined is not explained.

Created on 27 Jan 2016  Â·  12Comments  Â·  Source: freeCodeCamp/freeCodeCamp

Challenge Return Early Pattern for Functions has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

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

// Change values below to test your code
abTest(2,2);

undefined is not explained so someone trying to complete this challenge could easily be confused. The example given returns a string which also adds to the confusion.

All 12 comments

What would you propose as some explanation that would have been helpful to you?

I ran into the same problem. Perhaps a reminder that undefined is not supposed to be a string.

They should have mentioned that undefined is not a string.

In Declare JavaScript Variables we already separate them (undefined and string) as two different data types and we have Understanding Uninitialized Variables which talks about the undefined a little bit. When you're at Return Early Pattern for Functions it is supposed that you have finished that challenges and already know that undefined is not equal to "undefined" and that undefined and string are completely different data types. Also, the instructions say

Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

exit with a value of undefined not exit with a value of "undefined". So it doesn't say return the "undefined" string.

Yes, the instructions for this challenge are entirely correct and undefined is covered in earlier challenges. I know as a student, that returning the string “undefined” is a very easy mistake to make. I suggest adding a hint that you should not return a string will avoid confusion for some students.

Sincerely,
Ken Thompson

On Jan 29, 2016, at 8:04 AM, Arsen Melikyan [email protected] wrote:

In Declare JavaScript Variables http://www.freecodecamp.com/challenges/declare-javascript-variables we already separate them as two different data types and we have Understanding Uninitialized Variables http://www.freecodecamp.com/challenges/understanding-uninitialized-variables which talks about the undefined a little bit. When you're at Return Early Pattern for Functions it supposed that you have finished that challenges and already know that undefined is not equal to "undefined" and that undefined and string are completely different data types. Also, the instructions say

Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

exit with a value of undefined not exit with a value of "undefined". So it doesn't say return the "undefined" string.

—
Reply to this email directly or view it on GitHub https://github.com/FreeCodeCamp/FreeCodeCamp/issues/6525#issuecomment-176767250.

This is a common question in the Help Rooms. Here is what I propose:

Hint
Remember that undefined is a keyword, not a string.

We could potentially link one or more words in that sentance to Understanding Uninitialized Variables

Thank you all for clearing the confusion. :) Have a nice day...

On Sat, Jan 30, 2016 at 12:50 AM, Rex Schrader [email protected]
wrote:

This is a common question in the Help Rooms. Here is what I propose:

_Hint_
Remember that undefined is a keyword, not a string.

We could potentially link one or more words in that sentance to Understanding
Uninitialized Variables
http://www.freecodecamp.com/challenges/understanding-uninitialized-variables

—
Reply to this email directly or view it on GitHub
https://github.com/FreeCodeCamp/FreeCodeCamp/issues/6525#issuecomment-176919654
.

Also had a bit of trouble with this one since I assumed it was a string that needed to be returned so I was looking in that direction for my error before I realized undefined is also a keyword after some searching

It's not something really touched upon much except in the text for these 2 exercises mentioned above, maybe an added exercise that specifically lets you work with undefined would be cool and help people understand it quicker

@SaintPeter
Another smartAss

_removed solution by mod_

@acobserver
Please do not post your solution on here. GitHub Issues are for reporting bugs on the website only.

Happy Coding!

Glad this post exists. I was very confused how to do undefined. The previous example the problem leads to doesn't really apply. I'm not sure how else it could have been explained but it wasn't clear to me. Maybe there needs to be a glossary of terms somewhere. It is very hard to go back and find what I am looking for in FCC

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ar5had picture ar5had  Â·  3Comments

itsmikewest picture itsmikewest  Â·  3Comments

danielonodje picture danielonodje  Â·  3Comments

kokushozero picture kokushozero  Â·  3Comments

raisedadead picture raisedadead  Â·  3Comments