Home › Forums › JavaScript › [1,2,3,4,5,6,7,8,9].shuffle() › Re: [1,2,3,4,5,6,7,8,9].shuffle()
July 20, 2013 at 4:33 pm
#143797
Kuzyo
Participant
before sleep was that
Array.prototype.shuffle = function() {
var len = this.length;
for ( var i = 0; i < len; i++ ) {
var ele = this*, pos = this[Math.floor(Math.random()*len)];
if(pos == undefined) {
pos = ele;
}
}
return this;
};