Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Foundations Variables Hoisting

MYFUNCTION (TRUE)

What does mean elevatorCloseButton(true) in this case? Thank you.

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>
Andrew Lima
Andrew Lima
5,233 Points

The value true in the parenthesis of elevatorCloseButton(); is sent to the function which then checks if the button is pushed. It will run the if clause.

If you set the value elevatorCloseButton(false); the code between the if statement within the function won't run :)

I hope this makes sense.

how it will know that if the button pushed or not? It is already written "pushed" in the function.

Andrew Lima
Andrew Lima
5,233 Points

The variable true will equal to 'pushed' variable of the function. Your function requires an argument in this case elevatorCloseButton(true); where true is the argument. pushed is just a name for a variable to be passed to the function and then worked within the function and returned.

You can rename it to: function elevatorCloseButton(isPushed) and will still give the same answer.

can we dismiss (true) and just put the function name with empty brackets?

Andrew Lima
Andrew Lima
5,233 Points

Hey Fuad,

Yes you can however your IF statement will need to change accordingly. Something along the lines of

```if (variable == true) { //do code if true } else { // do code if false }

Thank you Lima, I am experiencing problem understanding these booleans I will try to dig in over and over again ..

Andrew Lima
Andrew Lima
5,233 Points

No problem :)

Do the javascript basics :) Should clarify this better than I can :)