- In order to get numbers from other ranges (e.g 0-100), you can multiply the result by a specific number.
- At the run time, the seed is selected automatically. The user can not choose or reset the seed.
Usage and Purpose Explained
Theory is great, but we recommend digging deeper!
Results: Return Value
The example below returns a float number between 0 and 1 (e.g., 0.28992849082058536)
Beginner-Friendly Practice Exercises
Using the examples below, we will introduce you ways to get random numbers in other ranges than 0-1. The first one will return a random number between 0 and 100:
Math.random() * 100;
Now, the example below will return a random number between 100 and 500:
(Math.random() * 400) + 100;