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 trialAlexandra Velez
Front End Web Development Techdegree Student 9,313 PointsWhy 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.
const temperature = 37.5;
const tempRounded = Math.round(temperature);
const tempRoundDown = Math.floor(tempRounded);
3 Answers
Mohammad Azawi
Courses Plus Student 5,631 PointsI 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
Alexandra Velez
Front End Web Development Techdegree Student 9,313 PointsI realize that with the TempRoundDown variable I used tempRounded in place of temperature. Thank you for helping me spot the error!
Mohammad Azawi
Courses Plus Student 5,631 PointsYou are welcome.
Keep it up :))