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 trialJohn Grinstead
3,169 PointsConditional 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.
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');}
<!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
231,271 PointsIt's just a spelling issue. You wrote "greather" instead of "greater" on the last line.
Matthew Long
28,407 PointsYour 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?
John Grinstead
3,169 PointsJohn Grinstead
3,169 PointsThank you so much, I feel kinda dumb now
Steven Parker
231,271 PointsSteven Parker
231,271 PointsSometimes it just takes another pair of eyes.