Skip to content

Instantly share code, notes, and snippets.

@oosugi20
Created November 9, 2012 03:52
Show Gist options
  • Save oosugi20/4043590 to your computer and use it in GitHub Desktop.
Save oosugi20/4043590 to your computer and use it in GitHub Desktop.
Shaffle the staffs
Array.prototype.shuffle = function() {
   var i = this.length;
   while(i){
       var j = Math.floor(Math.random()*i);
       var t = this[--i];
       this[i] = this[j];
       this[j] = t;
   }
   return this;
}
arr = ['makino', 'oosugi', 'moriko', 'hosono', 'rin'];
arr.shuffle();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment