while循环(javascript)
代码
<script>
function myFunction(){
var x="",i=0;
while (i<50){
x=x+i+"<br>";
i+=2;
}
document.getElementById("demo").innerHTML=x;
}
</script>
分析

image.png
这个和for循环的要素是一样的。只不过写的顺序不一样罢了。
<script>
function myFunction(){
var x="",i=0;
while (i<50){
x=x+i+"<br>";
i+=2;
}
document.getElementById("demo").innerHTML=x;
}
</script>
这个和for循环的要素是一样的。只不过写的顺序不一样罢了。