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) Working With Numbers Using Math Methods

Luis Roman
Luis Roman
1,511 Points

I get a well done, I'm doing great and this is completely wrong. Teamtreehouse please fix, and what am I doing wrong?

If I select "Check Work", I get a job well done. however, on challenge task #2 I get an error telling me to check Task #1. MDN isn't helping either. Just a page with a bunch of code that I do not understand. Can anyone explain in "code" why the 37.5 doesn't round to 38 and how to use the Math.floor along with the alert and temperature variable. In code, please and thank you.

script.js
var temperature = 37.5;
Math.round(temperature);
alert(temperature);
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

Steven Parker
Steven Parker
229,644 Points

Your code rounds the value, but doesn't store it anywhere. Then the alert just shows the original value. So combine these lines together to show the rounded value:

alert(Math.round(temperature));

Then leave that line as is and add another one like it (but with a different function) for task 2.

Luis Roman
Luis Roman
1,511 Points

Ohhhhhhh. lol. Thanks Man I appreciate it.