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

For this Code Challenge you need to use JavaScript's Math methods. Declare a new variable named tempRounded. Assign it

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

9 Answers

Chidiebere Ekennia
Chidiebere Ekennia
5,950 Points

There's a few bugs in your code Sahmad. First, You needed to declare tempRounded as a variable using either the "let" or "var" keywords. Second, You make a little mistake by in the last line of code. There's a syntax error there. It should have been: let tempRounded = Math.round(temperature); Hope this helps

Thanks

kkellerman
kkellerman
15,633 Points
const temperature = 37.5;
const tempRounded = Math.round(temperature);
const tempRoundDown = Math.floor(temperature);
const temperature = 37.5;

let tempRounded = Math.round(temperature);

let tempRoundDown = Math.floor(temperature);

Hi Sahmad, Thanks for inviting me to this challenge. I feel I have a good understanding of JavaScript but even so a quick little Google search helped. W3Schools is an excellent resource. Hope this helped.

https://www.w3schools.com/jsref/jsref_obj_math.asp

PS. The question asks you to store it as a variable. You were very close, you only forgot to assign the variable.

Shanna vick-Morris
Shanna vick-Morris
6,683 Points

const temperature = 37.5; let tempRounded (Math.round(temperature)); the error I am getting is unexpected token

Thank you! Chidiebere Ekennia, jlampstack

Shanna const temperature = 37.5; let tempRounded (Math.round(temperature));

Sahmad const temperature = 37.5; let tempRounded = Math.round(temperature);

Shanna vick-Morris
Shanna vick-Morris
6,683 Points

I am still getting an unexpected token error. Maybe it's the system?

const temperature = 37.5;

let tempRounded = Math.round(temperature);

let tempRoundDown = Math.floor(temperature);

let tempRounded = Math.round(temperature);

let tempRoundDown = Math.floor(temperature);

Answer: let tempRounded = Math.round(temperature);