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

boolean

The next few challenges are going to be using boolean logic and will be building in complexity.

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. i dont know what to do

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>
Curtis Slone
Curtis Slone
Courses Plus Student 13,318 Points

fill in the correct boolean operator in the parenthesis. Focus on the javascript code in the script.js file.

The goal is to make the script work.

to do that you need to fill in the conditional... what goes in the parenthesis?

if (??ANSWER_HERE??) { alert("this is true"); } else { alert("this is false"); }

What needs to be in the conditional for the first statement to come up? Which boolean statement?

Remember: A boolean statement is only either true or false.

1 Answer

Boolean values are either true or false, and what he is asking is to choose which one will make the first alert run. So we need to put in the value that will execute the first block of code. If we set it to true then it will execute the first code block.

if (true) {     //  <-- the boolean value we need to execute the first block goes in the parentheses.
    alert('this is true'); // Only runs if we set the value in parentheses to true.
} else  {  
    alert('this is false');  //Only runs if condition is set to false by putting false in the parentheses.
}

//Change comment to answer