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

i pass the first step and when i check the second step, i get an alert that my first step no longer works.

seems like there is a bug on this question.

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

Thomas Fildes
Thomas Fildes
22,687 Points

Hi Wade,

It is strange that this isn't working for you because there doesn't seem to be anything wrong with your code. Here is the code that i used to pass this challenge.

var temperature = 37.5;

alert(Math.round(temperature));
alert(Math.floor(temperature));

I can only assume the reasoning behind it is the fact you have created two variables to store the temperature variable rounded up and down (roundUp and roundDown) which is not necessary in this challenge; you just need to create two alert methods rather than writing two extra lines of code.

That worked. Learned something new there as well. Thank you Thomas!