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

Jose Sanchez
Jose Sanchez
7,849 Points

Placing a boolean value that will result in true being returned. Its working fine in google chrome?

I have tried this code to in the workspace provided by google chrome and its returning true as a boolean. I am not sure what I am doing wrong here.

script.js
var correctGuess = true;
if (correctGuess === true ) {
    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>

Hi,

The following code worked for me in the code challenge.

var booleanValue = true; 

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

The conditional statement takes the value of the variable but not the variable itself. Im not sure why but you should be able to pass the challenge with the code above! Cheers

2 Answers

Kim Still
Kim Still
7,355 Points

Your code is working fine for me. I get the "This is true" alert as expected.

Do you have alerts blocked somehow?

Jose Sanchez
Jose Sanchez
7,849 Points

Thanks, I just copied and past Amadeep's code since something weird is going on. All the other code challenges work fine but for someone reason this one does not. I understand the concept so that is what is important.

Jose,

I am glad I could help. If my answer was helpful dont forget to up vote it!

Cheers