showing results for - "javascript program printing the lyrics to the 99 bottles of beer song web"
Cary
29 Mar 2016
1for (var numberOfBottles = 99; numberOfBottles >= 0; numberOfBottles--) {
2    var bottleWord = "bottle";
3   if (numberOfBottles <= 0) {
4      bottleWord = "bottles";
5      console.log("No more " + bottleWord + " of beer on the wall."); 
6      console.log("No more " + bottleWord + " of beer,");
7      console.log("Go to the store and buy some more, 99 bottles of beer on the wall");
8   }
9   else if (numberOfBottles == 1 ) {
10       bottleWord = "bottle";
11       console.log(numberOfBottles + " " + bottleWord + " of beer on the wall");
12       console.log(numberOfBottles + " " + bottleWord + " of beer,");
13       console.log("Take one down, pass it around,");
14   }
15   else if (numberOfBottles >= 2) {
16       bottleWord = "bottles";
17       console.log(numberOfBottles + " " + bottleWord + " of beer on the wall");
18       console.log(numberOfBottles + " " + bottleWord + " of beer,");
19       console.log("Take one down, pass it around,");
20 
21   }
22       
23}