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

Petya Katsarova
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Petya Katsarova
Front End Web Development Techdegree Graduate 21,342 Points

i cant write correctly the parseInt value and am not sure where exactly to put it in the code

afdsf

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

1 Answer

Hi there,

You're really close here, and you have the right idea - you don't need to parseInt() at all. When the variables are declared at the top, they do not have quotes around them, which means they are already being stored as integers - no parsing needed! A string variable can be identified by either single (') or double(") quotes. Also, be careful when the instructions ask you to compare values - I noticed you use the greater than or equal to operator, but the challenge instructions just ask for greater than. When I tried with >=, it failed, so I think it does check for that. So, you can just do something like this:

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

Does that make sense? Let me know if you still have trouble.

Happy coding!