Skip to content

Instantly share code, notes, and snippets.

@icemancast
Last active October 5, 2015 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icemancast/f20b7650330c972830ef to your computer and use it in GitHub Desktop.
Save icemancast/f20b7650330c972830ef to your computer and use it in GitHub Desktop.

Assignments

Write a loop that will display the song "99 Bottles of Beer on the wall";

For Loop

Write a for loop that will iterate from 0 to 10. For each iteration of the for loop, it will multiply the number by 9 and log the result (e.g. "2 * 9 = 18").

for(var i = 9; i <= 10; i++) {
  for() {
    //
  }
}

Add a second multiplier and 3rd using an outer loop.

Do While Loop or While Loop

99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.

Be careful on last one

1 bottle of beer on the wall, 1 bottle of beer.
Take one down and pass it around, no more bottles of beer on the wall.
No more bottles of beer on the wall, no more bottles of beer. 
Go to the store and buy some more, 99 bottles of beer on the wall.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment