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

Norman Fernandez
Norman Fernandez
11,804 Points

hello i think the exercise of hosting has a bug can you fix it please?

i tried in other console with console.log and it¨s works

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) {
    var status = "I'll close when I'm ready.";
        if (pushed) {
      status

        }

    }

    elevatorCloseButton(true);

    </script>
  </body>
</html>

1 Answer

Alex Heil
Alex Heil
53,547 Points

hey norman Fernandez , this challenge is all about the best practices, so in the previous videos it was explained that we should declare our variable at the beginning of the function (just a blank one) and then later assign the value IF needed.

so by putting these ideas into the challenge the function would look like this:

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

hope that helps and have a nice day ;)

Norman Fernandez
Norman Fernandez
11,804 Points

Thanks for your help :-), i did not see it jejeje