-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsongs.js
More file actions
40 lines (35 loc) · 906 Bytes
/
songs.js
File metadata and controls
40 lines (35 loc) · 906 Bytes
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
function singTheBottlesOfBeerSong(bottles) {
let song = "";
for (loop = bottles; loop >= 0; loop--) {
song = song + bottlesofbeeronthewall(loop) + "\n";
}
//console.log(song);
return song;
}
function singTheFourBottlesOfBeerSong() {
return singTheBottlesOfBeerSong(4);
}
function bottlesofbeeronthewall(bottles) {
switch (bottles) {
// multiple cases go to the same line of code
case 0:
case "no":
case "No":
case "zero":
case "Zero":
return "no bottles of beer on the wall, go to the store and buy some more.";
break;
case 1:
case "one":
case "One":
return "one bottle of beer on the wall,";
break;
default:
return bottles + " bottles of beer on the wall,";
}
}
module.exports = {
singTheBottlesOfBeerSong,
singTheFourBottlesOfBeerSong,
bottlesofbeeronthewall,
};