Skip to content

Instantly share code, notes, and snippets.

@seunggabi
Created May 4, 2019 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seunggabi/d018657da5b15a4b50ce1693d12446c0 to your computer and use it in GitHub Desktop.
Save seunggabi/d018657da5b15a4b50ce1693d12446c0 to your computer and use it in GitHub Desktop.
shuffle.js
function shuffle(arr) {
var i = arr.length;
var random;
var temp;
while (i > 0) {
random = Math.floor(Math.random() * i--);
temp = arr[i];
arr[i] = arr[random];
arr[random] = temp;
}
return arr;
}
@seunggabi
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment