Created
December 11, 2014 14:36
-
-
Save ganey/ef0ee94bc555ca9d61fd to your computer and use it in GitHub Desktop.
Fisher Yates JS Secret Santa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = "joe tom dave mike mark sue lauren".split(" "), b = 0, c = a, d, e, f, g = c.length; | |
for (d = 0;d < g;d++) { | |
f = ~~(Math.random() * (d + 1)), e = c[d], c[d] = c[f], c[f] = e; | |
} | |
for (a = c;b < a.length;) { | |
console.log(a[b] + " => " + (b + 1 < a.length ? a[b + 1] : a[0])), b++; | |
} | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Concise!