Created
August 31, 2015 12:28
-
-
Save laispace/59179ca4f1644cca856f to your computer and use it in GitHub Desktop.
Revisions
-
laispace created this gist
Aug 31, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ function randomArray (array) { if (array.length === 1) { return array; } else { var len = array.length; var index = ~~(Math.random() * len); var item = array.splice(index, 1); return item.concat(randomArray(array)); } } var array = [1,2,3,4,5,6]; var result = randomArray(array); console.log(result)