Skip to content

Instantly share code, notes, and snippets.

@atoko
Created October 31, 2019 12:55
Show Gist options
  • Save atoko/ee7f39cb90ab2fc81fab3e9c5ca787d9 to your computer and use it in GitHub Desktop.
Save atoko/ee7f39cb90ab2fc81fab3e9c5ca787d9 to your computer and use it in GitHub Desktop.
let shuffle = function(array) {
for (var c = array.length - 1; c > 1; c--) {
var r = (Math.random() * c).toFixed(0);
var one = array[r];
var two = array[c];
if (one !== null) {
array[c] = one;
array[r] = two;
}
}
return array;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment