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 trialstarr13
2,494 PointsChallenge Task 1 of 1 JavaScript Basics: Conditional statements
Am I suppose to use symbols verse the words 'greater than' or 'less than'? I just not having any luck getting this to work. Please help me. Thanks!
var a = 10;
var b = 20;
var c = 30;
if a {
console.log('a is greater than b)=alert('a is greater than b'))
}else { alert('a is not greater than b')}
<!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>
3 Answers
Robert Bennett
11,927 PointsHere you go...
if( a > b){
alert('a is greater than b');
} else {
alert( 'a is not greater than b');
};
Andrew Buckner
2,506 PointsI was a little confused on why we did not have to use the curly brackets like normal if & else statements?
Ari Misha
19,323 PointsHello there, @JuliaCook! I think you didn't really get the question. The challenge says if a is greater than b, we need to alert some statement, else we need to alert some other statement. Here is how your statement should look like:
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')
I hope it helped!
~ Ari
starr13
2,494 PointsThanks, Ari!!!!
Julia
starr13
2,494 Pointsstarr13
2,494 PointsRobert,
Thanks for your help.
Julia