Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Storing and Tracking Information with Variables Review Creating and Naming Variables

why 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

Hi 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;

Zero 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. :)