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

Timothy Moran
Timothy Moran
2,730 Points

Conditional statement in Javascript if ( a > b) else is not found

I'm thinking treehouse is expecting a particular layout of code as this works and executes ok from what i can see.

The error message i'm getting is " Bummer ! don't see the message 'a is NOT greater then b'

3 Answers

Aaron Loften
Aaron Loften
12,464 Points

You spelled "than" as "then"

Aaron Loften
Aaron Loften
12,464 Points

Correct it as "a is NOT greater than b"

I would directly copy and paste this as the result. It will be easier. Real clients will flip out when messages are different than expected as well. Copy and paste will cover your butt.

Timothy Moran
Timothy Moran
2,730 Points

Cant believe it was that simple, thanks

Timothy Moran
Timothy Moran
2,730 Points

My code is below

var a = 10;
var b = 20;
var c = 30;

if ( a > b ) {
  alert("a is greater then b");  
} else { 
  alert("a is not greater then b"); 
}

var a = 10; var b = 20; var c = 30;

if ( a > b ) { alert("a is greater then b");
} else { alert("a is NOT greater than b"); }

Aaron Loften
Aaron Loften
12,464 Points

Hey Timothy,

It looks like you may have possibly forgotten the else portion. I am assuming they do not want an "else if" but it specifically says you have to have a handling for when it is not greater than b. That makes me think they may want an "else if" but id start with an "else" since treehouse likes to be direct.

Hope this helps.

IF it doesnt help, please post the entire code.