我遵循了一个非常基本的瓶装啤酒教程(与本网站上已经提到的不同),我不明白这部分是做什么的:
var bottlesDiv = document.
Run Code Online (Sandbox Code Playgroud)
这里有完整的代码(它确实按预期工作):
var bottles = 99;
var lyrics = "";
while (bottles > 0) {
lyrics = lyrics + bottles + " bottles of beer on the wall <br>";
lyrics = lyrics + bottles + " bottles of beer <br>";
lyrics = lyrics + "Take one down, pass it around, <br>";
bottles = bottles - 1;
if (bottles > 0) {
lyrics = lyrics + bottles + " bottles of beer on the wall <br><br>";
} …Run Code Online (Sandbox Code Playgroud)