Created
September 30, 2012 08:19
-
-
Save kinopyo/3806238 to your computer and use it in GitHub Desktop.
Javascript shuffle array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.shuffle = function() { | |
var len = this.length; | |
var i = len; | |
while (i--) { | |
var p = parseInt(Math.random()*len); | |
var t = this[i]; | |
this[i] = this[p]; | |
this[p] = t; | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment