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 trialorange sky
Front End Web Development Techdegree Student 4,945 PointsMath.random() include Zero and ONE or just what is in between?
Hello!
Does Math.random() return '1' as well? or does it return and number between Zero and 0.9999? What about Zero , does it return Zero?
2) If I want a number, including the number 0 and 10, would Math.random() * 10 return: the following numbers too: 0, 9.999, 10 ?
2 Answers
Chris Shaw
26,676 PointsSee the below which has all you need.
MDN's explanation
The Math.random() function returns a floating-point, pseudo-random number in the range [0, 1) that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range.
orange sky
Front End Web Development Techdegree Student 4,945 PointsThanks!!!