1.
? ? ? ? ? while(條件){
? ? ? ? 當條件為真時執(zhí)行
? ? ? ? ? }
? ? ? ? ? while中結(jié)束循環(huán)用break;
用while表示10個相同的數(shù)字;
var a=0;
while(a<10){
document.write('1')
a++;
}

while循環(huán)
用while表示1-100之間所有的偶數(shù);
1、
? var i=0;
while(i<=100){
if(i%2===0){
console.log(i);
}
i++;
}
2、
? ? ?? var i=2;
while(i<=100){
console.log(i++);
i++;
}
3、
var i=0;
while(i<=100){
console.log(i);
i+=2;
}

shile偶數(shù)
用while表示1-100之間所有的奇數(shù);
1、
var i=0;
while(i<=100){
if(i%2===1){
console.log(i);
}
i++;
}
2、
var i=1;
while(i<=100){
console.log(i++);
i++;
}
3、
var i=1;
while(i<=100){
console.log(i);
i+=2;
}

while奇數(shù)