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 trialeva rios mb
Courses Plus Student 3,948 PointsBoolean basic code
What is wrong with this?
var bigGuy = true; if (bigGuy) { alert('This is true'); } else { alert('This is false'); }
var bigGuy = true;
if (bigGuy) {
alert('This is true');
} else {
alert('This is false');
}
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
Amandeep Dindral
8,915 PointsHi,
The following code worked in the code challenge for me
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
4 Answers
Amandeep Dindral
8,915 PointsDale Severude If you look in the right hand corner there is a box that says "View Challenge" and you can actually go to the challenge. I didnt know this either but it has been super helpful for me to do the challenge and then give an answer.
Just in case you didnt know because I didnt know for a long time!
Happy coding
Seth Kroger
56,413 PointsNormally that should work. I've tried a couple of different ways myself and the challenge wants the specific answer if (true)
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 PointsGot it. I didn't realize this was in reference to passing a specific code challenge.
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 PointsThanks Amandeep, for some reason I didn't see that giant red button on the top right! LOL
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 PointsDale Severude
Full Stack JavaScript Techdegree Graduate 71,350 PointsHi Eva, This code is well formed (no errors) and produces an alert box that displays the message "This is true". Are you expecting a different result?