|
|
|
|
|
|
|
|
<head> |
|
|
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> |
|
|
<title> continue _1 </title> |
|
|
</head> |
|
|
|
|
|
<body> |
|
|
|
|
|
<script type="text/javascript"> |
|
|
//<!CDATA[ |
|
|
|
|
|
/* Sum up all the numbers from 1 to 50 except the multiples of 3. |
|
|
|
|
|
break exits completely, |
|
|
continue skips only the items that satisfy the condition, |
|
|
and keeps running the rest. */ |
|
|
*/ |
|
|
|
|
|
var sum=0; |
|
|
|
|
|
for(i=1;i<51;i++){ |
|
|
if(i&3==0) continue; |
|
|
sum+=i; |
|
|
} |
|
|
document.write(sum); |
|
|
|
|
|
//]]]]> |
|
|
</script> |
|
|
|
|
|
</body> |
|
|
</html> |
← Back to feed
Renewal·서른의 생활코딩
Sample source 2) Basic JavaScript document structure ( continue and break statements )
This English version was translated by Claude.
