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 Using Comparison Operators

My browser is displaying the message 'a is not greater than b' even though the challenge message is saying that it's not

The alert box pop's up 'a is not greater than b' in my browser, however the challenge is saying that it does not see the message. Also, the if condition alert box does not pop up either. What's the malfunction here? My condition statement's are typed exactly like the video display's them. What is the dealio?

script.js
var a = 10;
var b = 20;
var c = 30;
if (a>b) { alert('a is greater than b')
}
else { alert('a is not greather than b');
}
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>

2 Answers

Ioannis Leontiadis
Ioannis Leontiadis
9,828 Points

Hello Nathan,

I hope you have already figured it out but if not, here is the problem,

if (a>b) { alert('a is greater than b')
}

You have forgot the semicolon after your alert statement. This is a common mistake so try using better indentation and style techniques. This reads better no?

if( a > b ){ 
    alert('a is greater than b');
}
Joel Bardsley
Joel Bardsley
31,249 Points

The problem is the misspelling of the word 'greater' in the alert method within the else statement. The output for these types of challenges needs to be exactly right, otherwise it will fail you for minor issues like this.