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!
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
Ajla N
17,674 PointsCode Challenge: Hoisting
I can't figure out what I'm doing wrong, I've tried to do this challenge so many times now!
This is my code so far:
function elevatorCloseButton(pushed) {
var status = "I'll close when I'm ready.";
if (pushed) {
CONSOLE.LOG(STATUS);
}
}
elevatorCloseButton(true);
It keeps telling me "You should assign the 'status' in the if statement". The only way I know how is to use the console.log, that's what was used in the video. I just can't figure this one out!
Any help would be really appreciated! :)
3 Answers

Armando Amador
6,813 PointsHey Ajla N
You have to declare the variable status in the beginning of your function. Once the variable is declared, you are able to use it in the if section of your function.
function elevatorCloseButton(pushed) {
var status;
if (pushed) {
status = "I'll close when I'm ready.";
}
}
elevatorCloseButton(true);

Ajla N
17,674 Pointsedit

Michael Maloof
4,581 PointsWow thank you so much! I seriously looked through the forums for an hour and no one else could figure it out!
Ajla N
17,674 PointsAjla N
17,674 PointsThank you sooo so much!!! :D
Armando Amador
6,813 PointsArmando Amador
6,813 PointsYou're welcome, glad to help!