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 trialSantosh Kumar
2,232 PointsWhy is my code not passing? It seems correct!
I'm doing https://teamtreehouse.com/library/javascript-basics-2/working-with-numbers/using-math-methods
In challenge task 2, according to me, it should work.
var temperature = 37.5;
alert(Math.floor(temperature));
But it's not!
var temperature = 37.5;
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
MIke Allen
9,727 PointsHi Santosh,
Do you still have the code in from task 1? I just checked it on my end and it worked fine with the following code.
var temperature = 37.5
alert(Math.round(temperature));
alert(Math.floor(temperature));
Jonathan Grieve
Treehouse Moderator 91,253 PointsThe code is correct, but you need to use Math.round instead of Math.floor()
We're rounding the number up instead of down. :-)
Santosh Kumar
2,232 PointsSantosh Kumar
2,232 PointsYes, The previous code needs to be there.
Jonathan Grieve
Treehouse Moderator 91,253 PointsJonathan Grieve
Treehouse Moderator 91,253 PointsIndeed, yes you're right, we're using 2 methods here across both tasks :)