Skip to content
Permalink
Browse files

Fix fisher-yates πŸ™ˆ

  • Loading branch information
pakastin committed Mar 26, 2020
1 parent 9765209 commit 8d3be56c56950afe787b6217bc3993ebeab62e9c
Showing with 6 additions and 6 deletions.
  1. +6 βˆ’6 lib/fisherYates.js
@@ -1,13 +1,13 @@

export default function (array) {
var rnd, temp
var rnd, temp;

for (var i = array.length - 1; i; i--) {
rnd = Math.round(Math.random() * i)
temp = array[i]
array[i] = array[rnd]
array[rnd] = temp
rnd = Math.floor(Math.random() * (i + 1));
temp = array[i];
array[i] = array[rnd];
array[rnd] = temp;
}

return array
return array;
}

0 comments on commit 8d3be56

Please sign in to comment.
You can’t perform that action at this time.