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

Max Botez
Max Botez
5,146 Points

I've got confused what do I need to do.

Hi all, I've really got confused what do I need to do in this exercise? Could someone give me a hand of help, to guide what to do?!

Thanks, Max

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

2 Answers

So all the exercise does is asks you to write a conditional statement to test whether a is greater than b or not, and based on that, pop up an alert. In your code here, you're trying to completely redefine a using a (misspelled) prompt. All you need to do is:

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

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

Not sure if the else is necessary, but the question's instructions don't tell you what to do if the two are equal...

Max Botez
Max Botez
5,146 Points

It's simpler than I was thinking. By your example I got how to resolve it. Also I've got confused because there isn't nothing about var c = 30; so I thought I need to use it as well

PS. Yep, I saw that I misspelled prompt after submitted the question.

Thank you so much.