forked from CodePlatoon/algo-99-bottles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path99_bottles_justfunction.js
28 lines (23 loc) · 1.15 KB
/
99_bottles_justfunction.js
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
function main() {
for (let i = userbeerbottles; i > 2 && i<=99; i--) {
console.log(i, "bottles of beer on the wall,", i, "bottles of beer.");
console.log("Take one down and pass it around,", i - 1, "bottles of beer on the wall.");
}
if (userbeerbottles === 2) {
console.log("2 bottles of beer on the wall, 2 bottles of beer.");
console.log("Take one down and pass it around, 1 bottle of beer on the wall.");
} else if (userbeerbottles === 1) {
console.log("1 bottle of beer on the wall, 1 bottle of beer.");
console.log("Take one down and pass it around, no more bottles of beer on the wall.");
}
if(userbeerbottles>0&& userbeerbottles<=99){
console.log("1 bottle of beer on the wall, 1 bottle of beer.");
console.log("Take one down and pass it around, no more bottles of beer on the wall.");
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, 99 bottles of beer on the wall.");
}else {
console.log("Error Pick a number from 1 to 99");
}
}
let userbeerbottles = 98;
main();