Skip to content

Instantly share code, notes, and snippets.

@frayhan32
Last active December 23, 2015 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frayhan32/6568683 to your computer and use it in GitHub Desktop.
Save frayhan32/6568683 to your computer and use it in GitHub Desktop.
Random int
//*****************************************************************//
/*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