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 Making Decisions in Your Code with Conditional Statements Use Comparison Operators

keller greathouse
keller greathouse
4,351 Points

Add a conditional statement that tests if the value in variable a is greater than the value in variable b. If it is, log

The error is telling me that I am not logging in that a is not greater than b. But I clearly am in my else conditional.

script.js
var a = 10;
var b = 20;
var c = 30;
if (a>b){console.log("a is greater than b.");}
else {console.log("a is NOT greater 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>

1 Answer

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

This is one of those times where it's unfortunate how picky the backend of the challenge is being. What you have is fine, though I'm not sure why the change from consts to vars but that doesn't matter for this one.

You just need to remove the periods from the end of your console log strings.

var a = 10;
var b = 20;
var c = 30;
if (a>b){console.log("a is greater than b");}
else {console.log("a is NOT greater than b");}
keller greathouse
keller greathouse
4,351 Points

Thank you! I do not know why it made a deal about my periods in that statement.

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

I know some of these challenges are extremely specific in what they want. I'm sorry you got held up on that one but at least your logic and code was valid and correct!