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 trialSteve Leichman
7,008 PointsHoisting 'if' statement issue.
So, I've done the step of moving the variable to where it needs to be, but now it's telling me:
Bummer! You should assign the 'status' in the if statement.
I've tried a few iterations of what I'd thought to be correct, but obviously none of it has been. What belongs in the if statement that I'm missing?
Thanks!!!!!!
Alter the 'elevatorCloseButton' function to follow the best practices in declaring variables within the scope of the function.
<script>
function elevatorCloseButton(pushed) {
var status = "I'll close when I'm ready.";
if (pushed) {
}
}
elevatorCloseButton(true);
</script>
1 Answer
Steve Leichman
7,008 PointsFigured it out:
<script>
function elevatorCloseButton(pushed) {
var status;
if (pushed) {
status = "I'll close when I'm ready.";
}
}
elevatorCloseButton(true);
</script>