d Я пытаюсь использовать цикл для отображения детской песни "10 зеленых бутылок, висящих на стене".Итак, я начинаю цикл с 10 и до 0. Текст должен складываться, и, наконец, все песни должны отображаться
для i = 10 i = 0 i--, а текст внутри цикла,Числа должны меняться, но остальные должны остаться прежними
<div id="demo"></div>
<script>
function favsong() {
var i;
var song = "";
var poem = "green bottles, hanging on a wall";
var poem1 ="If 1 green bottle were to accidentally fall. There'd be";
for (i=10;i=0;i--) {
song+=i+poem+"<br>"+i+poem+"<br>"+poem1;
if (i==1){
song+="1 green bottle hanging on the wall"+"<br>+"1 green bottle hanging on the wall"
continue
}
}
document.getElementById("demo").innerHTML = song;
}
</script>
10 green bottles, hanging on a wall,
10 green bottles, hanging on a wall,
If 1 green bottle were to accidentally fall
There'd be 9 green bottles, hanging on the wall
9 green bottles, hanging on a wall,
9 green bottles, hanging on a wall,
If 1 green bottle were to accidentally fall
There'd be 8 green bottles, hanging on the wall
8 green bottles, hanging on a wall,
8 green bottles, hanging on a wall,
If 1 green bottle were to accidentally fall
There'd be 7 green bottles, hanging on the wall
... and so on...
1 green bottles, hanging on a wall,
1 green bottles, hanging on a wall,
If 1 green bottle were to accidentally fall
There'd be 0 green bottles, hanging on the wall