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 trialJason Larkin
13,970 PointsHoisted Variables Problem
I am finishing up a unit on hoisted variables, but the prompt that the challenge gives me, that the "status" should be within the elevatorCloseButton seems to have nothing whatever to do with the preceding video lesson. Can anyone help please?
Here is the HTML? js :
function elevatorCloseButton(pushed) {
if (pushed) {
var status = "I'll close when I'm ready.";
}
}
elevatorCloseButton(true);
</script>
Sage Elliott
30,003 PointsWhich course is it in?
Jason Larkin
13,970 PointsIt's in the JavaScript Foundations course- Variables.
2 Answers
Sage Elliott
30,003 PointsTry declaring your variable before the if statement.
function elevatorCloseButton(pushed) {
var status;
if (pushed) {
status = "I'll close when I'm ready.";
}
}
elevatorCloseButton(true);
Sage Elliott
30,003 PointsThis passes the code challenge for me. I just confirmed. Did you make any other changes?
function elevatorCloseButton(pushed) {
var status
if (pushed) {
status = "I'll close when I'm ready.";
}
}
elevatorCloseButton(true);
Sage Elliott
30,003 PointsYou can try refreshing incase some other code was edited.
Jason Larkin
13,970 PointsJason Larkin
13,970 PointsThank you but now it says that I have to declare 'status' above the 'elevatorCloseButton' , whatever that means. I really wish I could figure this out but the video doesn't cover any of this.