sendou.ink/utils/shuffleArray.js
2020-01-02 02:49:24 +02:00

14 lines
242 B
JavaScript

//https://stackoverflow.com/a/6274381
function shuffle(a) {
var j, x, i
for (i = a.length - 1; i > 0; i--) {
j = Math.floor(Math.random() * (i + 1))
x = a[i]
a[i] = a[j]
a[j] = x
}
return a
}
module.exports = shuffle