求100以内偶数的和
<script>
let sum = 0 //定义一个变量来存放累加的和
for (let i = 0; i <= 100; i++) {
if (i % 2 == 0) { //对2取余为0即为偶数
sum += i //进行累加
}
}
console.log(sum); //控制台打印结果
</script>
标签:以内,sum,累加,偶数,let,100
From: https://www.cnblogs.com/zerotwo-zrx/p/17340668.html