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

Now what am I doing wrong?

So based on the lesson this looks right but no matter how I type it the program says either Syntax error or Parse error. What am I missing and why don't they have more specific help in the lesson?

script.js
var a = 10;
var b = 20;
var c = 30;
if ( answer.toUpperCase () a > b ) {
  alert(document.write("<p>a is greater than b</p>"));
} else {
  alert(document.write("<p>a is not greater than b</p>"));
}
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>

the toUpperCase was added after it came up in an error message, otherwise it doesn't make sense and I have tried it with and without

4 Answers

Ben Spears
Ben Spears
19,148 Points
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');
}
Julian Gutierrez
Julian Gutierrez
19,201 Points

You are correct that answer.toUppercase() is not needed. The challenge is asking you to alert your message only, so there is no need for document.write or the p tags.

I will try taking out the document.write and the <p> tags. Thank you!

Ben Spears
Ben Spears
19,148 Points

to start, the conditional statement should only check if (a >b)

Thank you both, I was overthinking it and trying to add too much code, this helped out a lot! Thank you again!