Currently, I am working on a textbook exercise that involves the classic 99 Bottles of Beer on the wall JavaScript program. However, this assignment does not come with any examples or answers for reference. Despite searching online for assistance, the code I found differs greatly from what I have been taught in the book so far. One issue I encountered is that when the bottle count reaches one, the output displays "1 bottles" instead of "1 bottle". I'm unsure where I went wrong but I am excited to understand and improve! Thank you in advance for your help! Below is a link to the jsfiddle.
var word = "bottles";
var count = 99;
while (count > 0) {
console.log(count + " " + word + " of beer on the wall ");
console.log(count + " " + word + " of beer,");
console.log("Take one down, pass it around,");
count = count - 1;
if (count > 0) {
console.log(count + " " + word + " of beer on the wall.");
if (count === 1)
word = "bottle";
} else {
console.log("No more bottles of beer on the wall.");
}
}