mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-07 10:34:46 -04:00
Fixed world.rand.shuffle for arrays of length 0 or 1.
This commit is contained in:
parent
09e969405a
commit
6954175fa8
1 changed files with 1 additions and 0 deletions
|
@ -41,6 +41,7 @@ class Rand
|
|||
|
||||
# shuffle array in place, and also return it
|
||||
shuffle: (arr) =>
|
||||
return arr unless arr.length > 2
|
||||
for i in [arr.length-1 .. 1]
|
||||
j = Math.floor @randf() * (i - 1)
|
||||
t = arr[j]
|
||||
|
|
Loading…
Add table
Reference in a new issue