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 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!