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

Challenge Task 1 of 1 JavaScript Basics: Conditional statements

Am I suppose to use symbols verse the words 'greater than' or 'less than'? I just not having any luck getting this to work. Please help me. Thanks!

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

3 Answers

Robert Bennett
Robert Bennett
11,927 Points

Here you go...

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

Robert,

Thanks for your help.

Julia

I was a little confused on why we did not have to use the curly brackets like normal if & else statements?

Ari Misha
Ari Misha
19,323 Points

Hello there, @JuliaCook! I think you didn't really get the question. The challenge says if a is greater than b, we need to alert some statement, else we need to alert some other statement. Here is how your statement should look like:

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')

I hope it helped!

~ Ari

Thanks, Ari!!!!

Julia