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 Review Numbers

senay yakut
senay yakut
4,124 Points

javascript

which of the following stores the number 225,622 in the variable milesToTheMoon? A - var milesToTheMoon ='225622'; B- var milesToTheMoon=225622; C- var milesToTheMoon=225,622;

I assume I am giving the right answer but it doesn't work

4 Answers

It's actually B, not C. This is because JavaScript is picky, and JavaScript doesn't except commas inside of numbers. Commas ar enot allowed in numbers, in other words. B looks just like C, but without those commas.

Note: You can always press Command and Shift and i at the same time (on Mac) or Ctrl and Shift and i (on Windows) to open up the JavaScript console to write JavaScript.

senay yakut
senay yakut
4,124 Points

I am thinking C is the right one

You're welcome! :)

Ali .
Ali .
15,521 Points

answer is : var milesToTheMoon=225622;