DEV Community

Discussion on: Rando.js: replacing Math.random()

Collapse
 
mrspartak profile image
Spartak

It is using Math.random, just added sugar around it.
Made a ton prototypes long time ago for such tasks

Array.prototype.getRandom = function () {
    return this[Math.floor(Math.random() * this.length)];
};
console.log( [1, 2, 3].getRandom() )