Skip to content

Instantly share code, notes, and snippets.

@danielbonnell
Created September 25, 2014 17:53
Show Gist options
  • Save danielbonnell/b30bd29bbfb040b47411 to your computer and use it in GitHub Desktop.
Save danielbonnell/b30bd29bbfb040b47411 to your computer and use it in GitHub Desktop.
Codeschool: Javascript Roadtrip II Challenge
var numSheep = 4;
var monthsToPrint = 12;
for(var monthNumber = 1; monthNumber <= monthsToPrint; monthNumber++) {
if (monthNumber % 4 = 0) {
numSheep *= .75;
var removed = numSheep;
console.log("Removing " + removed + " sheep from the population. Phew!");
} else if (numSheep > 10000) {
numSheep /= 2;
var removed = numSheep;
console.log("Removing " + removed + " sheep from the population. Phew!");
} else {
}
numSheep*=4;
console.log("There will be " + numSheep + " sheep after " + monthNumber + " month(s)!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment