MCPcopy Index your code
hub / github.com/BrainJS/brain.js / shuffleArray

Method shuffleArray

src/cross-validate.js:46–54  ·  view source on GitHub ↗

* Randomize array element order in-place. * Using Durstenfeld shuffle algorithm. * source: http://stackoverflow.com/a/12646864/1324039

(array)

Source from the content-addressed store, hash-verified

44 * source: http://stackoverflow.com/a/12646864/1324039
45 */
46 shuffleArray(array) {
47 for (let i = array.length - 1; i > 0; i--) {
48 let j = Math.floor(Math.random() * (i + 1));
49 let temp = array[i];
50 array[i] = array[j];
51 array[j] = temp;
52 }
53 return array;
54 }
55
56 /**
57 *

Callers 3

trainMethod · 0.95
browser.min.jsFile · 0.80
browser.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected