Javascript String randomBetween(min, max)

Description

Javascript String randomBetween(min, max)


String.prototype.randomBetween = function(min, max) {

 var hash = this.getHashCode();
     // w  ww  .j a  va2  s .c  o m
    min = min || 0;
    max = max || 1;
    
    var seed = (hash * 9301 + 49297) % 233280;
    var rnd = Math.abs(seed / 233280.0);
        
    return min + rnd * (max - min);
    
};



PreviousNext

Related