<!doctype html> <html> <head> <meta charset="utf-8"> <title>退出循环break</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){ document.write("成绩为"+mynum[i]+"不必继续循环输出"+"<br />"); break; } document.write("成绩为:"+mynum[i]+"可以继续循环输出"+"<br />"); i=i+1; } </script> </head> <body> </body> </html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>退出循环break</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){
document.write("成绩为"+mynum[i]+"不必继续循环输出"+"<br />");
break;
}
document.write("成绩为:"+mynum[i]+"可以继续循环输出"+"<br />");
i=i+1;
}
</script>
</head>
<body>
</body>
</html>