Skip to content

Instantly share code, notes, and snippets.

@desinas
Last active February 14, 2020 16:52
Show Gist options
  • Save desinas/e6b8cffb352aba86f8cfe47cd70843db to your computer and use it in GitHub Desktop.
Save desinas/e6b8cffb352aba86f8cfe47cd70843db to your computer and use it in GitHub Desktop.
99 Bottles of juice Quiz of Udacity Front end developer
/*
* 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 > 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!");
num -= 1;
}
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!");
num = num - 1;
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!");
@desinas
Copy link
Author

desinas commented Dec 16, 2017

What Went Well

  • Your code should have a variable num with a starting value of 99
  • Your code should include a while loop
  • Your while loop should have a stop condition
  • Your code should produce the expected output

Feedback: Your answer passed all our tests! Awesome job!

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