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


alex nonya
alex nonya
Courses Plus Student 9,265 Points

Random integer Module? Is there a module to import to simply ask for a random int between a start and stopping number?

This is such an inefficient way of generating random numbers, are there any modules that have created better methods?

I recently used Python3 to simply state randint(1, 10), which would give you a random integer between 1 and 10.

Why all the extra steps with Javascript?

1 Answer

Steven Parker
Steven Parker
228,991 Points

The random function for picking integers in range is a well-known (and well-documented) formula that is easily implemented. The course shows how to do it in a single line.

As Piotr suggested, if you think you might use it frequently, you can always create your own library of functions and include it.