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 Basics (Retired) Making Decisions with Conditional Statements Booleans

I am not sure what they are asking here

do I have to come up with an string so the boolean maske it true ?

script.js
if ( ) {
    alert('This is true');
} else {
    alert('This is false');
}
index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

2 Answers

Agnes Demes
Agnes Demes
6,613 Points

Hi here its asking to place a boolean after the if statement to be executed if true and not if its not true eg you simply need to type if(true) withing the parenthesies

Hi Neils,

Let's see the official challenge statement :

Place a Boolean value between the parenthesis for the condition in this conditional statement. Use the boolean value that >will result in the message "This is true" appearing in an alert box.

Now the code :

if ( ) {
    alert('This is true');
} else {
    alert('This is false');
}

It wants you to put something inside those round parentheses so that the alert message "This is true" runs.

if(condition){
  //run if condition is true
}
else {
  //run if condition is false
}

so in order to solve this challenge here's the code:

if ( true ) {
    alert('This is true');
} else {
    alert('This is false');
}

We simply put true inside if condition so that the part after it runs.

I hope it clears things up, Happy Coding and have a great day :)

  • Zain