Skip to content

Instantly share code, notes, and snippets.

@M-Drummond
Created January 18, 2016 00:44
Show Gist options
  • Save M-Drummond/3ecd3963a5b41150ebcf to your computer and use it in GitHub Desktop.
Save M-Drummond/3ecd3963a5b41150ebcf to your computer and use it in GitHub Desktop.
javascript loop
var numSheep = 4; // number of sheep
var monthNumber = 1; // counting month
var monthsToPrint = 12; // max length of loop
while (monthNumber <= monthsToPrint) { // while months is less than the max length
numSheep *=4; // multiply the number by 4
console.log("There will be " + numSheep + " sheep after " + monthNumber + " month(s)!" ) ; // output concat. string
monthNumber++ ; // increment the month - will only occur below the maximum amount.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment