Javascript Array takeRandom()

Description

Javascript Array takeRandom()


Array.prototype.takeRandom = function() {
 if (!this.length) { return null; }
 var index = Math.floor(ROT.RNG.getUniform() * this.length);
 return this.splice(index, 1)[0];
}



PreviousNext

Related