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

Matthew Paley
Matthew Paley
1,298 Points

Hmmmmmm? Not sure whats being asked here. Moved var status up outta if but if is now empty. added console.log(status)

Asking for status in if???

function elevatorCloseButton(pushed) { var status = "I'll close when I'm ready.";

if (pushed) {
   console.log(status); //not correct here
}

}

elevatorCloseButton(true);

2 Answers

Sage Elliott
Sage Elliott
30,003 Points

Hopefully this thread from earlier will help you out good sir. https://teamtreehouse.com/forum/hoisted-variables-problem

Matthew Paley
Matthew Paley
1,298 Points

Aaaaahhhhhh-ha! That clears it up perfectly. Just like the video... simply declare first then assign the value later. Makes sense. Thx Sage!

Sage Elliott
Sage Elliott
30,003 Points

Always glad to help! Make sure you check the post as being answered so it no longer show up as unanswered.

Code on!

Matthew Paley
Matthew Paley
1,298 Points

How is "check the post is answered' done exactly? Click the unsubscribe btn???