dreamer2015
2015-03-01 13:40
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>continue</title>
<script type="text/JavaScript">
var mynum =new Array(70,80,66,90,50,100,89);//定义数组mynum并赋值
var i=0;
while(i<mynum.length)
{
if(mynum[i]<60)
{
continue;
}
document.write("成绩:"+mynum[i]+"及格,输出!"+"<br>");
i++;
}
</script>
</head>
<body>
</body>
</html>
if(mynum[i]<60)这里遇到小于60的话,因为i没自增,会死循环。。。
var arr=[80,96,75,50,60,100,92,50,62]; var i=-1; while(i<arr.length-1) { i++; if(arr[i]<70) { document.write("成绩不好,不输出。"+"<br>"); continue; } else{ document.write("成绩是:"+arr[i]+"<br>"); } }
<script type="text/JavaScript"> var mynum =new Array(70,80,66,90,50,100,89);//定义数组mynum并赋值 var i=0; while(i<mynum.length) { if(mynum[i]<60) { document.write("成绩不及格,不输出!"+"<br>"); i++; continue; } document.write("成绩:"+mynum[i]+"及格,输出!"+"<br>"); i++; } </script>
JavaScript进阶篇
468063 学习 · 21891 问题
相似问题