Created
January 18, 2016 00:44
-
-
Save M-Drummond/3ecd3963a5b41150ebcf to your computer and use it in GitHub Desktop.
javascript loop
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 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