Skip to content

Instantly share code, notes, and snippets.

@bgadrian
Created March 16, 2015 17:27
Show Gist options
  • Save bgadrian/6d38db99c51de6dd762b to your computer and use it in GitHub Desktop.
Save bgadrian/6d38db99c51de6dd762b to your computer and use it in GitHub Desktop.
JS random numbers and chance generator
/** random inclusive 2 integer positive numbers */
function rdm(min,max)
{
return (Math.floor(Math.random()*max+1)+min);
}
/** It has p % chances to result true ! p must be between 1 and 99 ! */
function rdmp(p)
{
return (rdm(0,100) <= p)?true:false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment