Last active
March 11, 2023 04:33
-
-
Save sayyedhammadali/aa098e46b9b1aab4b8e1729a66bc695d to your computer and use it in GitHub Desktop.
Get a random number in a specific range
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const randomNumberInRange = (min = 0, max = 100) => Math.floor(Math.random() * (max - min + 1)) + min; | |
randomNumberInRange() | |
// Result: Default random number range is 0 - 100, so you get a number between 0 and 100. | |
randomNumberInRange(100, 200) | |
// Result: You will get a random number between 100 and 200, where 100 is min range and 200 is max range. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment