Skip to content

Instantly share code, notes, and snippets.

@rockitude
Last active August 29, 2015 14:01
Show Gist options
  • Save rockitude/c0c844f0affb3e3ec034 to your computer and use it in GitHub Desktop.
Save rockitude/c0c844f0affb3e3ec034 to your computer and use it in GitHub Desktop.
Build a random building from an array of possibilities
var cottage = function(){
console.log("Building a cottage.");
};
var mansion = function(){
console.log("Building a mansion.");
};
var buildings = [cottage, mansion];
while(buildings.length > 0){
var choice = Math.floor(Math.random() * buildings.length);
//replace this line with a function that builds a building
buildings[choice]();
buildings.splice(choice, 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment