Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJessica Andhika
257 Pointswhy is this incorrect? var timeRemaining = 0;
the question was to fill in the blank below, showing the variable timeRemaining and not to put any values.. var[blank];
2 Answers
Fernando Boza
25,384 PointsHi Jessica, basically 0 is still a value, so
var example = 0 ... you're placing the number 0 in the variable.
To make an empty variable just add nothing, literally. var example;
Kai Nightmode
37,045 PointsZero is something in JavaScript. Specifically zero is a number.
I think it can help to see what JavaScript considers things by running the following code to double check.
var timeRemaining;
console.log('"var timeRemaining" is of the type: ' + typeof(timeRemaining)) // undefined
timeRemaining = 0;
console.log('"timeRemaining = 0" is of the type: ' + typeof(timeRemaining)) // number
timeRemaining = 'hello';
console.log('"timeRemaining = \'hello\'" is of the type: ' + typeof(timeRemaining)) // string
Try running the above code to double check and see how the type of timeRemaining changes depending on what you do or do not assign to it. :)