Created
June 17, 2021 07:33
-
-
Save kaleem-elahi/505f88be112f740f6e5654f91b41b594 to your computer and use it in GitHub Desktop.
how to get a Random number in a Range of Values
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 getRandomIntInRange = (min, max) => Math.floor(Math.random() * (max-min +1)) + min; | |
// 3 examples added to show how to use it: | |
/* | |
getRandomIntInRange(1, 5); | |
Output: 1 | |
getRandomIntInRange(1, 5); | |
Output: 4 | |
getRandomIntInRange(1, 5); | |
Output: 1 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment