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

Bit confused with whether the function work or not

what if math.random generate a number close to 0.99, with the low number being 10 and the high being 100.

there will be chances where it is actually a number of 100 instead 11 to 99?

https://teamtreehouse.com/community/video:110093

1 Answer

Steven Parker
Steven Parker
231,153 Points

The possible range of numbers depends on both the formula used and the parameters given. The formula shown in the video is inclusive of the limits, so if you provide 10 and 100 as the limits, you could indeed get the number 10 as a result, or 100, or any number in between.

There are other formulas that are exclusive of the limits, so 10 and 100 would give you a number from 11 to 99, but that formula is not shown in the course video.

oh that makes sense now i thought they are developing a formula for random number up to 99 only