showing results for - "javascript shuffle string"
Karl
24 Sep 2016
1String.prototype.shuffle = function () {
2    var a = this.split(""),
3        n = a.length;
4
5    for(var i = n - 1; i > 0; i--) {
6        var j = Math.floor(Math.random() * (i + 1));
7        var tmp = a[i];
8        a[i] = a[j];
9        a[j] = tmp;
10    }
11    return a.join("");
12}
13console.log("the quick brown fox jumps over the lazy dog".shuffle());
14//-> "veolrm  hth  ke opynug tusbxq ocrad ofeizwj"
15
16console.log("the quick brown fox jumps over the lazy dog".shuffle());
17//-> "o dt hutpe u iqrxj  yaenbwoolhsvmkcger ozf "
18
Blake
05 Apr 2020
1var shuffled = str.split('').sort(function(){return 0.5-Math.random()}).join('');
2
queries leading to this page
js function that shuffles a stringshuffle array of string javascriptjs shuffle string lettersshuffle words in string javascriptshuffle a single string in javascripthow to shuffle string characters in jshow to break into pieces shuffle string in javascript javascript every shuffle of stringhow to get back a string from a shuffle string in nodejsstr shuffle jsshuffle an array of strings in javascriptjs randomize stringrandom order string jsjavascript shuffle array of stringsshuffle array of stringsjavascriptrandomly rearrange string in jsshuffle a sting in javascriptshuffle array of strings javascriptstr shuffle in javascriptjavascript random shuffle stringjavascript shuffle stringjs sort random stringjs string shuffleshuffle string javascript charathow to shuffle strings in javascriptmix string randomly jshow to shuffle string in javascriptstring shuffle javascriptjavascript string shufflehow to scramble a string in javascriptjs shuffle string arrayshuffle a string in javascriptrandomize order of string js1528 shuffle string javascriptrandom shuffle characters from a string in javascriptshuffle string node jshow to shuffle a substring in javascriptjavascript take a string and shufflt its contentscramble string jshow to get back a string from a shuffle string in node jsrandomy shuffle an array of stirngs jsstring shuffle 2funshuffle javascripthow to shuffle characters in a string in jshow to shuffle array of strings in javascriptjs shuffle string onlineshuffle string jsshuffle array of strings jsshuffle string javascriptshuffle an array of strings in js random mix string javascripthow to shuffle the alphabet in jsstring letters shuffle jsstring shuffle jsshuffle characters in a string javascriptjavascript shuffle string arrayshuffle string in jshow ot shuffle characters in string jsshuffle a string javascripthow to shuffle a js stringsort string randomly javascriptjavascript scramble stringjs shuffle stringhow to convert shuffle string in javascriptswitch string randomly javascriptshuffle substrings in javascriptscramble string javascripthow to shuffle a string in javascriptjavascript shuffle string