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

tayjoh
tayjoh
2,329 Points

Complete the code below to create a variable named timeRemaining (don't assign a value to the variable).

Complete the code below to create a variable named timeRemaining (don't assign a value to the variable).

var ______ ; (fill in the blank to the left)

My answer: timeRemaining = ""

X Bummer!

Anyone know the answer? Thank you in advance =)

3 Answers

Olga DC
Olga DC
16,680 Points

You only have to declare the variable, not assign a value to it. In your code, you are assigning it a value of an empty string. You only have to write this:

var timeRemaining;

You are technically setting the variable to an empty string. If you open the console in developer tools and type in

var timeRemaining = "";
console.log(timeRemaining) 

it's going to return a blank line.

var timeRemaining;
console.log(timeRemaining)

this is going to return undefined which is what the quiz is looking for

tayjoh
tayjoh
2,329 Points

Thank you so much everyone for the quick and informative answers. I'll be sure to never make that mistake again. =)