<script type="text/javascript">
//计算人的一生, 1-100岁
var i = 1;
do {
console.log('今年'+i+'岁了');
i++;
} while ( i<=100 );
//计算1-100整数的和
var he = 0;
var i = 1;
do {
he = he + i;
i++;
} while ( i <=100 );
console.log(he);
//弹窗
do {
var text = prompt('你是人是狗?')
} while (text !== '狗')
alert('人不如苟');
</script>
js do while实现3个案例:循环1-100岁;1-100整数的和;弹窗循环效果
最新推荐文章于 2024-03-26 20:15:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)