Q:

How do you shuffle an array in Coffeescript?

How do you shuffle an array in Coffescript?

A:

Fisher–Yates shuffle from github (modified):
fisherYates = (arr) ->
    i = arr.length
    return arr unless i > 0

    while --i
        j = Math.floor(Math.random() * (i+1))
        [arr[i], arr[j]] = [arr[j], arr[i]] # use pattern matching to swap

