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

Conditional Statement

When I attempt to write a conditional statement with var a being greater than var b I did so as "if (a > b)" yet the challenge is telling me that's incorrect, but when I try something else it asks me if I'm using the "<" symbol. I do not understand what is incorrect with this code.

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

Steven Parker
Steven Parker
229,732 Points

It's just a spelling issue. You wrote "greather" instead of "greater" on the last line.

Thank you so much, I feel kinda dumb now

Steven Parker
Steven Parker
229,732 Points

Sometimes it just takes another pair of eyes. :wink:

Matthew Long
Matthew Long
28,407 Points

Your conditional statement is correct. You have a spelling error. It should be greater instead of greather in your else clause:

var a = 10;
var b = 20;
var c = 30;

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

Also, the way you wrote it made it hard to read. Especially, if you had more lines of code. You might want to consider breaking your code onto new lines?