Created
August 22, 2017 03:02
-
-
Save claudiainbytes/cc0f2dad34f52c386f1fad31b70addc1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
* Programming Quiz: 99 Bottles of Juice (4-2) | |
* | |
* Use the following `while` loop to write out the song "99 bottles of juice". | |
* Log the your lyrics to the console. | |
* | |
* Note | |
* - Each line of the lyrics needs to be logged to the same line. | |
* - The pluralization of the word "bottle" changes from "2 bottles" to "1 bottle" to "0 bottles". | |
*/ | |
var num = 99; | |
while ( num >= 1 ) { | |
if ( num > 2 ) { | |
console.log(num + " bottles of juice on the wall! " + num +" bottles of juice! Take one down, pass it around... " + (num-1) + " bottles of juice on the wall!"); | |
}else if ( num === 2 ){ | |
console.log(num + " bottles of juice on the wall! " + num +" bottles of juice! Take one down, pass it around... " + (num-1) + " bottle of juice on the wall!"); | |
}else{ | |
console.log(num + " bottle of juice on the wall! " + num +" bottle of juice! Take one down, pass it around... " + (num-1) + " bottles of juice on the wall!"); | |
} | |
num--; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment