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 Numbers The Math Object Use Math Methods

Alexandra Velez
seal-mask
.a{fill-rule:evenodd;}techdegree
Alexandra Velez
Front End Web Development Techdegree Student 9,313 Points

Why isn't the Math.floor working in this variable?

The variable is named. The temperature is specified The Math.floor seems to be spelled and spaced correctly.

script.js
const temperature = 37.5;
const tempRounded = Math.round(temperature);
const tempRoundDown = Math.floor(tempRounded);

3 Answers

I don't understand your code because you rounded the number(the number became '38' ) then you used floor function on the result of that rounded number(38) which will be the same result for both variables .

if you wanna different result:

const temperature = 37.5;

const tempRounded = Math.round(temperature);
console.log(tempRounded); // result 38

const tempRoundDown = Math.floor(temperature);
console.log(tempRoundDown);// result 37

You are welcome.

Keep it up :))