Skip to content

Instantly share code, notes, and snippets.

@manfromanotherland
Created August 7, 2015 23:45
Show Gist options
  • Save manfromanotherland/5f56291cb2e294effbe3 to your computer and use it in GitHub Desktop.
Save manfromanotherland/5f56291cb2e294effbe3 to your computer and use it in GitHub Desktop.
JS: selecting a random dwarf from a list
var luckyDraw = ["Thorin", Fili", Kili", Balin", Dwalin", Oin", Gloin", Dori", Nori", Ori", Bifur", Bofur", Bombur"];
function pickRandomPerson(luckyDraw){
var index = Math.floor(Math.random() * (luckyDraw.length -1));
return luckyDraw[index];
}
pickRandomPerson(luckyDraw);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment