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


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

<!DOCTYPE html>
<html lang="en">
    <title> JavaScript Foundations: Variables</title>
      html {
        background: #FAFAFA;
        font-family: sans-serif;
    <h1>JavaScript Foundations</h1>
    <h2>Variables: Hoisting</h2>


    function elevatorCloseButton(pushed) {

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



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 :)