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 trial

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
STAFF
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.