Last active
December 23, 2015 02:39
-
-
Save frayhan32/6568683 to your computer and use it in GitHub Desktop.
Random int
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
//*****************************************************************// | |
/*getRandomint function to return random number in range min and max you supply*/ | |
/*very useful for me when building captcha*/ | |
//*****************************************************************// | |
function getRandomInt (min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
//*************TEST HIM*************// | |
alert(getRandomInt(1,5)); | |
//will produce random number in range 1 to 5 | |
//*********************************// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment