Created
August 12, 2018 16:44
-
-
Save JCloudYu/bcf7d1aad606a635642ae83861e8f5c2 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
String.prototype.shuffle = function(){ | |
var a = this.split(""), | |
n = a.length; | |
for( var i = n - 1; i > 0; i-- ){ | |
var j = Math.floor(Math.random() * (i + 1)); | |
var tmp = a[i]; | |
a[i] = a[j]; | |
a[j] = tmp; | |
} | |
return a.join(""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment