Created
May 26, 2018 10:57
-
-
Save gupta-ji6/77723eeb0f9aeb83ac665c25860e1313 to your computer and use it in GitHub Desktop.
Revisions
-
gupta-ji6 created this gist
May 26, 2018 .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,22 @@ function copy(o) { var output, v, key; output = Array.isArray(o) ? [] : {}; for (key in o) { v = o[key]; output[key] = (typeof v === "object") ? copy(v) : v; } return output; } const shuffle = (array) => { let currentIndex = array.length, temp, randomIndex; while (currentIndex !== 0) { randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; temp = array[currentIndex]; array[currentIndex] = array[randomIndex]; array[randomIndex] = temp; } let arr = copy(array); return arr; };