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.
Adama Sy
7,076 Pointschallenge code hoisting I dont understand what they asking witht he first question
Alter the elevator....
really I dont get it anyone online to help
4 Answers

Philip Cox
14,818 PointsJavascript Hoisting explains how JS with automatically bring your variables above other code for cache purposes. This may end up effecting your scope and shadowing of variables. or accidentally rewriting a variable.
You will have to elaborate on your question please.
Adama Sy
7,076 Points<!DOCTYPE html> <html lang="en"> <head> <title> JavaScript Foundations: Variables</title> <style> html { background: #FAFAFA; font-family: sans-serif; } </style> </head> <body> <h1>JavaScript Foundations</h1> <h2>Variables: Hoisting</h2>
<script>
function elevatorCloseButton(pushed) {
if (pushed) {
var status = "I'll close when I'm ready.";
}
}
elevatorCloseButton(true);
</script>
</body> </html>
Adama Sy
7,076 PointsAlter the 'elevatorCloseButton' function to follow the best practices in declaring variables within the scope of the function.

Joshua Russo
10,037 PointsI've tried all different combinations and cannot get this answer. Where do we define the variable? I would think it needs to be defined before the function but also called after the if statement in the function as well.. Any help is appreciated!
Ben Junya
12,365 PointsBen Junya
12,365 PointsI second Phillip Cox's answer.
Also, we have no idea what you're asking. What's confusing about it? Phillip did a pretty good job explaining hoisting.
Adama Sy
7,076 PointsAdama Sy
7,076 PointsI did it I simply had to move var status on top to declare it. then had status=""; after the if.
thanks