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 trialAugustine von Trapp
9,060 PointsI can't figure out what is wrong.
I tested the program in Workspaces and it functions exactly as the code challenge describes, however whenever I run it in the code challenge it tells me it "doesn't see the the 'a is not greater then b' message.
Can anyone tell me what is wrong?
I would love to get on with this section! Thank you!!
var a = 10;
var b = 20;
var c = 30;
if (a > b) {
alert('a is greater then b')
}
else {
alert('a is not greater then 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>
1 Answer
Marcus Parsons
15,719 PointsHi Augustine,
Your code works fine, but this is just a simple spelling error in your strings inside both alert()
commands. You should have "than" not "then", and once you fix that, your challenge will pass. Also, it's a good idea to add semi-colons to the end of any command because leaving them off can cause a debugging nightmare on bigger projects.
//change then to than
if (a > b) {
alert('a is greater than b');
}
else {
//change then to than
alert('a is not greater than b');
}
Augustine von Trapp
9,060 PointsAugustine von Trapp
9,060 Pointsokay, basic spelling error. Problem solved......