Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Why didn't my code run?

I have to do an objective, and the objective starts off with var a = 10 var b = 20 var c = 30 Here is my code that I typed.

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

2 Answers

Ken Howard
STAFF
Ken Howard
Treehouse Guest Teacher

The code needs to be written using the greater than operator >. Also, when referencing a variable you don't include the var keyword. var should only be used when assigning a value to a new variable name.

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

Thank you Ken.