mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 19:06:59 -05:00
Merge branch 'master' of https://github.com/jklemm/codecombat
This commit is contained in:
commit
398ac998ab
1 changed files with 1 additions and 0 deletions
|
@ -41,6 +41,7 @@ class Rand
|
||||||
|
|
||||||
# shuffle array in place, and also return it
|
# shuffle array in place, and also return it
|
||||||
shuffle: (arr) =>
|
shuffle: (arr) =>
|
||||||
|
return arr unless arr.length > 2
|
||||||
for i in [arr.length-1 .. 1]
|
for i in [arr.length-1 .. 1]
|
||||||
j = Math.floor @randf() * (i - 1)
|
j = Math.floor @randf() * (i - 1)
|
||||||
t = arr[j]
|
t = arr[j]
|
||||||
|
|
Loading…
Reference in a new issue