Created
March 22, 2023 13:04
-
-
Save periakteon/5e0789053916ddc33103b9c5374c5279 to your computer and use it in GitHub Desktop.
FreeCodeCamp: Generate Random Whole Numbers within a Range (Solution)
This file contains hidden or 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
function randomRange(myMin, myMax) { | |
return Math.floor(Math.random() * (myMax - myMin + 1) + myMin); | |
} | |
console.log(randomRange(5, 10)); | |
// 9 | |
console.log(randomRange(5, 10)); | |
// 10 | |
console.log(randomRange(5, 10)); | |
// 5 | |
console.log(randomRange(5, 10)); | |
// 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment