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

When on task 2, and leaving in task 1 code, does not the value just remain 38? My code validates in console. Stuck.

I am not able to proceed, says my code is incorrect but yet it validates in console. Snippet here:

var temperature = 37.5

temperature = Math.round(temperature);

alert(temperature);

temperature = Math.floor(temperature);

alert(temperature);

2 Answers

Hi Paul,

The code challenge doesn't want you to change the temperature value. Both the round and floor function should operate on the original value of 37.5

Rather than assign the return value of these functions back to temperature you should instead alert the return values directly.

Example: alert(Math.round(temperature));

This way you're alerting the 38 but still keeping the 37.5 in temperature.

Thanks Jason!

Dave McFarland
STAFF
Dave McFarland
Treehouse Teacher

Hi Paul the Schmit

The problem is that you're changing the actual value of the temperature variable:

temperature = Math.round(temperature);

After this code runs, the value in temperature is 38. Just alert the rounded value without changing the variable itself:

alert(Math.round(temperature));

Thanks Dave! Perhaps an update of the error messaging, a more appropriate hint would have pointed me in the right direction.