今天,讲课内容为循环语句。课后老师为了强化我们的记忆给我们布置了一些练习。
总的来说感觉今天的内容还是不算很难的,理解起来也还可以,结合数学上的逻辑思考还是能思考出来,下边是我今天的练习题。
100以内有关于7的数字:
<script>
var str = "";
for (var i = 7; i <= 100; i++) {
if (i % 7 == 0 || (i - 7) % 10 == 0 || i >= 70 && i < 80) {
str += i + ",";
}
}
alert(str);
</script>
100以内数的求和:
<script>
var s=0
for(var i=1;i<100;i++){
s=s+i
}
alert(s)
</script>
一个篮球从100米下落每次弹起高度为上一次的0.6倍,几次高度小于1米:
<script>
var height=100
var count=0;
while(true){
height = height * 0.6;
count++;
if(height<=1){
break
}
}alert(count)
</script>