Skip to content

Instantly share code, notes, and snippets.

@macikokoro
Last active August 29, 2015 14:03
Show Gist options
  • Save macikokoro/f07a98bd7c775bcc214e to your computer and use it in GitHub Desktop.
Save macikokoro/f07a98bd7c775bcc214e to your computer and use it in GitHub Desktop.
While loop with multiplication.
var numSheep = 4;
var monthNumber = 1;
var monthsToPrint = 12;
while(monthNumber <= monthsToPrint) {
numSheep *= 4;
console.log("There will be " + numSheep + " sheep after " + monthNumber + " month(s)!");
monthNumber++;
}
@macikokoro
Copy link
Author

This while loop will print = There will be (number of sheep) sheep after 1 month(s)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment