Skip to content

Instantly share code, notes, and snippets.

@jdittrich
Last active January 4, 2016 04:09
Show Gist options
  • Save jdittrich/8566984 to your computer and use it in GitHub Desktop.
Save jdittrich/8566984 to your computer and use it in GitHub Desktop.
takes the array and prints out all its entrys once, in random order
/*
Copyright © 2014 jdittrich
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
*/
var shuffleThis = [1,2,3,4,5,6]; //put any numbers or strings here
while(shuffleThis.length>0){
console.log(
shuffleThis.splice(
Math.floor(
Math.random()*shuffleThis.length-1
)//floor end
,1)//splice end
[0]//1st element of splices array
);//console end
};//while end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment