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

Where to add "status"?

I gave up on this. Where in the world should I add "status" in this code?

index.html
<!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>

2 Answers

Chris Shaw
Chris Shaw
26,676 Points

Hi evargas,

You simply need to declare status before the IF statement and reassign it's value if the condition for the said IF statement is true.

function elevatorCloseButton(pushed) {
  var status;

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

}

Happy coding!

But that's what I did and still got the wrong answer!

Coding is that weird.

But still thank you.