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

alan heath
alan heath
5,188 Points

okay...what am i doing wrong

So have put the var status above the if statement but then what next? I keep getting "you should assign the "status" in the if statement so i copied the example and placed within the if statement also here is what i have so far:

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

    }

    elevatorCloseButton(true);

2 Answers

James Barnett
James Barnett
39,199 Points

alan heath - The issue with your code, is you want to only set the status if the button has been pushed, not before.

Hi Alan,

You're close:

function elevatorCloseButton(pushed) {

    var status;

    if (pushed) {
        status = "I'll close when I'm ready.";
    }
}

elevatorCloseButton(true);

If you look to the bottom right of the text box you will see something that says Markdown Cheetsheet. If you don't understand that maybe this will make sense: How to display code at Treehouse

Jeff