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

Srdjan Cestic
Srdjan Cestic
6,855 Points

Where is problem?

I don't know how to pass this challenge, can anyone tell me where I go wrong?

5 Answers

Sebastian Astill
Sebastian Astill
3,629 Points

The condition statement needs to check whether the variable a is greater than b. The double and triple equals signs test to see if something is equal something else. Also you are comparing the variable a to the string "a". You are asking if 10 is equal to a. Instead your code should actually look like this

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 suggest you watch the video(s) again so that you understand it better. :)

Konrad Pilch
Konrad Pilch
2,435 Points

Well, first of all, you need to post your code, otherwise we have no idea where you go wrong.

Srdjan Cestic
Srdjan Cestic
6,855 Points

I was think that code will automatic show, because I post ask from challenge, but sorry anyway.

Here is code :

var a = 10;
var b = 20;
var c = 30;
(a > b);
if ( answer==="a" ) {
  alert("a is greater than b");
} else {
  alert("a is not greater than b");
}

EDIT: Please Check the code formating. Press edit and see what i did to achieve it please-K.P

Konrad Pilch
Konrad Pilch
2,435 Points

I think you need this

<

or this

>

in the place of three ===.

I suggest to go over the video again and check out what =, ==, ===, '<' ,' >' means.

Srdjan Cestic
Srdjan Cestic
6,855 Points

One = sign work, thanks.

Sebastian Astill
Sebastian Astill
3,629 Points

The equals (=) sign is the assignment operator, here you are just placing the value "a" in the variable called answer.

Konrad Pilch
Konrad Pilch
2,435 Points

Do you know what 'greater' means? Because these are things you need to know later on in programming.

Srdjan Cestic
Srdjan Cestic
6,855 Points

Thanks Sebastian for explanation, your solution is more direct and clearer to me.