<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> </body> <script type="text/javascript"> //方法一: var max=1; for(var ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
<script type="text/javascript">
//方法一:
var max=1;
for(var i=1;i<=100;i++){
if(i%7==0){
max=i
}
}
document.write(max);
document.write("<br/>");//換行
//方法二:
var max=1;
for (var i=100;i>=1;i--){
if(i%7==0){
max=i;
break;//結束迴圈體
}
}
document.write(max);
</script>
</html>