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 trialMatt Duarte
2,497 PointsConditional Statements
I cannot get the message to display when I enter the else command. Cn anyone help? If a is greater than b than the alert should pop up. Else message should pop up. var a = 10; var b = 20; var c = 30; if(a > b) { alert('a is greater than b'); } else { message = ("<p>"'a is not greater than b'"</p>"); }
var a = 10;
var b = 20;
var c = 30;
if(a > b) {
alert('a is greater than b');
} else {
message = ("<p>"'a is not greater than b'"</p>");
}
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHi Matheus,
You have the first alert()
right for the if statement
, but I'm confused on why you went a completely different way for the else clause
? The instructions are the same for both...
Both should have an alert()
, just with different sentences. The instructions don't say anything about adding HTML entities or using a variable.
Just fix up the else clause
to match the syntax of the code block inside the if statement
that you have and it will pass. Remember, challenges are very picky and instructions must be followed exactly of it will give you the Bummer
.
Keep Coding! :)