-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path99bottles_of_beer.js
More file actions
45 lines (39 loc) · 1.68 KB
/
Copy path99bottles_of_beer.js
File metadata and controls
45 lines (39 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// function displayLyrics() {
// var count = 99;
// var total = 0;
// var keyword = " bottles"
// while (count > 0) {
// console.log(count + keyword + " of beer on the wall, " + count + keyword + " of beer.");
// count--;
// total++;
// if (count === 1) {
// keyword = " bottle";
// }
// console.log("Take one down and pass it around, " + count + keyword + " of beer on the wall.");
// console.log("\n");
// if (count === 1) {
// console.log(count + keyword + " of beer on the wall, " + count + keyword + " of beer.");
// console.log("Take one down and pass it around, no more bottles of beer on the wall.");
// console.log("\n");
// break;
// }
// }
// total += 1;
// console.log("No more bottles of beer on the wall, no more bottles of beer.");
// console.log("Go to the store and buy some more, " + total + " bottles of beer on the wall");
// }
// displayLyrics();
var count = 100;
function beer() {
while (count >= 0) {
if (count >= 2) {
console.log(count + " bottles of beer on the wall, " + count + " bottles of beer. Take one down and pass it around, " + (count - 1) + " bottles of beer on the wall.");
} else if (count == 1) {
console.log(count + " bottles of beer on the wall, " + count + " bottles of beer. Take one down and pass it around, no more bottles of beer on the wall.");
} else {
console.log("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.");
}
count--;
}
}
beer();