Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements Using Comparison Operators

Conditional 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>"); }

script.js
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>");
}
index.html
<!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
MOD
Jason Anders
Treehouse Moderator 145,624 Points

Hi 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! :) :dizzy: