Skip to content

Instantly share code, notes, and snippets.

@AJ-Acevedo
Last active June 9, 2016 17:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AJ-Acevedo/8803295 to your computer and use it in GitHub Desktop.
Save AJ-Acevedo/8803295 to your computer and use it in GitHub Desktop.
Code School - Javascript Roadtrip Part 2 - Level 2 Challenges 7
var numSheep = 4;
var monthsToPrint = 12;
for(var monthNumber = 1; monthNumber <= monthsToPrint; monthNumber++) {
if ( monthNumber % 4 == 0 ) {
numSheep /= 4;
console.log("Removing " + (numSheep * 3) + " sheep from the population. Phew!");
}
else if ( numSheep > 10000 ) {
numSheep /= 2;
console.log("Removing " + numSheep + " sheep from the population. Phew!");
}
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