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 trialRay Edison Refundo
3,798 Pointsdisplay the temparature variable rounded downward to the nearest integer (hint: down is toward the "floor".)
I'm not exactly sure what's wrong with my code, can anyone elaborate what I did wrong?
var temperature = 37.5
var temperature = alert(Math.round(temperature));
var temperature = alert(Math.floor(temperature));
<!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
Tony Nguyen
24,934 PointsWaddup Ray!
Try entering your answer without making your alert boxes variables.
Justin Iezzi
18,199 PointsIt's only asking you to use the alert method. Since the temperature variable has been created, you don't need to create it again.
Try this, I've removed "var temperature =" from the second and third lines. You should notice that alert still functions without being assigned to the temperature variable.
var temperature = 37.5
alert(Math.round(temperature));
alert(Math.floor(temperature));
Ray Edison Refundo
3,798 PointsThanks for giving an elaborate explanation :), I understand now what I did wrong.
Ray Edison Refundo
3,798 PointsRay Edison Refundo
3,798 PointsOh, haha I got kind of confused I passed the exercise with
var temperature = 37.5 var temperature = alert(Math.round(temperature)); var temperature = alert(Math.floor(37.5));
and it worked but, yeah I realized I shouldn't even have to add the same variable towards the alerts. Thanks though!
Tony Nguyen
24,934 PointsTony Nguyen
24,934 PointsYou're welcome!