Skip to content

Commit 6da97dd

Browse files
authored
Swap the two using es6 deconstruction
1 parent 099d4ba commit 6da97dd

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/shuffle/fisheryates.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@
2020
function shuffle(array) {
2121
var size = array.length;
2222
var rand;
23-
var temp;
2423
for (var i = 0; i < size; i += 1) {
2524
rand = Math.floor(i + Math.random() * (size - i));
26-
temp = array[rand];
27-
array[rand] = array[i];
28-
array[i] = temp;
25+
[array[rand], array[i]] = [array[i], array[rand]];
2926
}
3027
return array;
3128
}

0 commit comments

Comments
 (0)