问答详情
源自:4-8 退出循环break

退出循环break

<!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>


提问者:Carrie_IT 2015-01-16 11:42

个回答

  • 踯躅
    2015-12-16 18:40:43

    <!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>