Created
May 10, 2017 01:34
-
-
Save brunomonteiro3/27af6d18c2b0926cdd124220f83c474d to your computer and use it in GitHub Desktop.
Generate random number between two numbers in JavaScript
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
function randomIntFromInterval(min,max){ | |
return Math.floor(Math.random()*(max-min+1)+min); | |
} |
function Numbers(min,max){
console.log(Math.floor(Math.random()*(max-min+1)+min));
}
Numbers(15, 20)
Thanks it´s working good 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@lourdrivera123 you do not need a "test case" for this situation because the "algorithm" does not return values greater than minimum and maximum. For more explanation about it you can read the mozilla guide.
But if you really want to, you can do something like that:
Again, you don't need to check this function, because you pass the min/max. On the mozilla guide, for the Math.random, you can find other random generator's.