Created
October 19, 2020 09:06
-
-
Save moaoa/ddd2026d1262d0af8b45478a7906484e to your computer and use it in GitHub Desktop.
This file contains 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
//One could (or should) use it as a protoype from Array: | |
//From ChristopheD: | |
Array.prototype.shuffle = function() { | |
var i = this.length, j, temp; | |
if ( i == 0 ) return this; | |
while ( --i ) { | |
j = Math.floor( Math.random() * ( i + 1 ) ); | |
temp = this[i]; | |
this[i] = this[j]; | |
this[j] = temp; | |
} | |
return this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment