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 trialThomas Katalenas
11,033 Pointswhy doesn't this pass!!
var temperature = 37.5; alert(Math.floor(temperature))
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>
7 Answers
Justin Olson
13,792 PointsGood day! Your code is nearly perfect, you are just missing the ; after the alert. Should show like this...
var temperature = 37.5; alert(Math.floor(temperature));
Bob McCarty
Courses Plus Student 16,618 PointsThomas,
Both floor() and round() achieve the same result in that they return an integer. But the quiz expects round() instead of floor(). By convention, the nearest integer to .5 is the next highest integer.
Bob
Gregor Cmiel
8,926 PointsHi Thomas,
you've missed a semicolon at the end of the second line:
...
alert(Math.floor(temperature))
But I think that the main problem could be your script path. Are you sure that your script is in the same directory like your index.html? Maybe it is in the js folder. Try to check it and fix the path according to your folder:
If the script.js is in the js folder your path should be:
...
<script src="js/script.js"></script>
...
Thomas Katalenas
11,033 PointsI did htat and it still didn't work
Bob McCarty
Courses Plus Student 16,618 PointsThomas,
What did not work? Did you try round()?
Bob
Thomas Katalenas
11,033 PointsI passed question 1 of 2 with the rounding function. problem 2 of 2 with floor method does not pass, might be a bug here is my code.
var temperature = 37.5;
alert(Math.floor(temperature));
did not work, I tried multiple times with and without semicolons, as well as changing script src = "script.js"> </script> to <script src = "js/script.js" ></script>
I think it is a bug in the console.
Bob McCarty
Courses Plus Student 16,618 PointsThomas,
This answer passed for me.
var temperature = 37.5;
alert(Math.round(temperature));
alert(Math.floor(temperature));