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 Foundations Variables Hoisting

Marguerite Seip
Marguerite Seip
10,762 Points

Hoisting challenge

Hello, I'm having trouble with the Hoisting challenge where I am supposed to declare the variable within the scope of the function. The variable is a string that I declare before the if statement but then I am also supposed to assign it after the if statement? I'm confused. Please help! -Marguerite

2 Answers

Dave McFarland
Dave McFarland
Treehouse Teacher

You've got it right. You should declare the variable at the top of the function (inside the function). But don't assign a value to it:

var status;

Then assign the value status="I'll close when I'm ready."; inside the if() statement.