Last active
August 29, 2015 14:01
-
-
Save rockitude/c0c844f0affb3e3ec034 to your computer and use it in GitHub Desktop.
Build a random building from an array of possibilities
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 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