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

i have a general question on Conditional Statements (cs).

i have a general question on Conditional Statements (cs). as i understaind it now, you put a condition inside the () and than follows {} with the code that should run.

my question is, is a cs always linked to a variable, or are the also scenario where you write a cs without a variable and in what cases? love to hear from you!

many thanks in advance.

1 Answer

Steven Parker
Steven Parker
231,248 Points

A condition doesn't always have to be based on a variable, though it's most common for it to be. An alternative example might be where the return value from calling a function could be tested as the condition:

    if (calculatePlayerScore() >= 100) {
        endGame("You Win!");
    }

thanks for the quick reply