Skip to content

Instantly share code, notes, and snippets.

@oti
Created September 28, 2016 03:32
Show Gist options
  • Save oti/fd048534e11a1dabc9badbfaa0163a2e to your computer and use it in GitHub Desktop.
Save oti/fd048534e11a1dabc9badbfaa0163a2e to your computer and use it in GitHub Desktop.
random integer
function randomInteger(range){
retunr Math.floor(Math.random() * range);
}
// <range> is range of number.
// randomInteger(2) // -> 0 or 1
// randomInteger(10) // -> 0,1,2,3,4,5,6,7,8,9
// randomInteger(100) // -> 0,1,2,...,98,99
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment