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

it says it's not greater

the statement is there

script.js
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");
  }
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>

5 Answers

Adam Beer
Adam Beer
11,314 Points

Just don't give up! :) The start is confused, but if you practice the your new knowledge, you come in! And here your code is fine, just shouldn't use apostrophs inside the if() statemenet. When you working with properties and you saved these properties into a variable, just put the variable name inside to the if () statement without apostrophs.

A few basic ideas:

Working with number

var number =  29;

if(number < 30) { // without apostrophs
  // This is true, because the number(29) less than 30
} else {
  // So now this is the false
}

or if you don't save the number inside the variable

if(29 > 30) { // without apostrophs
  // This is false, because the 29 not greater than 30
} else {
  // So now this is the true branch
}

Working with boolean values

var boolean = true/false;

if(boolean === true/fasle) { //without apostrophs

} 

or if you don't save the boolean value inside the variable, just put into the if () statement, like this,

if(true === false) { //without apostrophs
 //This is false ,
} else {
  //Now this is true because the if statement is false
}

Working with strings

var string = "JavaScript"; // This is a word so you can use apostrophes in the variable.

if(string === "Python") { // The string is a variable name so you shouldn't use apostrophes but it must be at the "Python" because it is a word
  // This statement is false, because string("JavaScript") not equal to "Python". 
} else {
  // This is true, because string("JavaScript") not equal to "Python"
}

if you don't save the string inside the variable, then you can put the string value into the if () statement, like this,

if("Javascript" === "Javascript") { // With apostrophes, because both is a word.
  // This is true, because "JavaScript" equal to "JavaScript"
} else {
  // This is false, because the first statement was true
}

The letters/words -> You can use apostrophes !!!

The numbers -> You shouldn't use apostrophes

The boolean values -> You shouldn't use apostrophes

The variable names -> You shouldn't use apostrophes

I hope this help for you! Don't give up! Repeat the cirriculum when you finisd a new course or section. Do not worry, just relax!

Adam Beer
Adam Beer
11,314 Points

Shouldn't use apostrophs in the if() statement if you compare variables.

var numbers || if (numbers);
with boolean values || if (true, false)
with string || if ("With String")

Thank you Adam. For some reason I'm drawing a complete blank right now. I don't understand why. I do appreciate your help

Adam Beer
Adam Beer
11,314 Points

And now with your new knowledge you solved this task?

Unfortunately no. For some reason my mind has shut down. I'm a disabled veteran who's blood pressure is too high. From a tbi they think. I'm kinda proud I got through this far. In just wish I could go on to the code Louisville classes. Thank you for your help

I never give up. I hate that I didn't get thru the last javascript class. I would have loved to have a mentor I could have physically worked with. You have been a great help. Everyone has been great. I just hope I qualify for code Louisville. I really want to program. And work in cybercrime and medical bio research. I'm a lifelong medic. USAF combat medic veteran. Again I really appreciate your help. I hope ill be back soon. 😁

Adam Beer
Adam Beer
11,314 Points

I hope too! I'm glad if you understood my examples and you learn from it :) This is a difficult thing, because the internet full of documentation and videos and great tutorials, like treeehouse or other sites. I hope you reach your dreams. Happy coding! :)