Created
January 13, 2011 21:13
-
-
Save mrandyclark/778614 to your computer and use it in GitHub Desktop.
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 pirates = ["pirate1", "pirate2", "pirate3", "pirate4", "pirate5"]; | |
var distanceToGo = 20; | |
var newPirates = true; | |
var getMorePirates = function(pirates) { | |
pirates.push( | |
"pirate" + | |
(pirates.length+1) | |
); | |
console.log("we've ordered some new pirates!"); | |
}; | |
var welcomePirates = function() { | |
console.log("ahoy new pirates!"); | |
}; | |
var swarmbuckleThePirates = function(pirates) { | |
pirates.pop(); | |
console.log("PIRATES HAVE BEEN SWARMBUCKLED!"); | |
}; | |
while(distanceToGo != 0) | |
{ | |
console.log("There are " + pirates.length + " pirates"); | |
if(pirates.length < 5) { getMorePirates(pirates); newPirates = true; } | |
if(newPirates) { welcomePirates(); } | |
if(Math.floor(Math.random()*3) == 1) { swarmbuckleThePirates(pirates); } | |
newPirates = false; | |
distanceToGo = distanceToGo - 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment