Javascript Random Number Function

2013-07-29 14:45:15


 /**
  * returns a random integer between max and min. 
  * If min is unspecified then it will be a random number between 0 and max
  */
function randint(max, min) {
    min = min || 0;
    var n = Math.floor(Math.random()*((max+1)-min));
    return min + n;
}