See the Pen break, continue by nilgi (@nilgi) on CodePen.
break : 반복 중단
<p id="bk1"></p>
<script>
let bk_text = "";
for (let n = 0; n < 11; n++) {
if (n === 5) { break; }
bk_text += "숫자 " + n + "<br/>";
}
document.getElementById("bk1").innerHTML = bk_text;
</script>
<p id="bk2"></p>
<script>
const gr = ["mc20", "mct", "fm", "lx"];
let gr_text = "";
list: {
gr_text += gr[0] + "<br/>.";
gr_text += gr[1] + "<br/>";
gr_text += gr[2] + "<br/>";
break list;
gr_text += gr[3] + "<br/>";
}
document.getElementById("bk2").innerHTML = gr_text;
</script>
continue : 반복 중에 조건에 맍는 값은 건너뛰기
<p id="ct1"></p>
<script>
let ct_text = "";
for (let m = 0; m < 11; m++) {
if (m === 6) { continue; }
ct_text += "숫자 " + m + "<br/>";
}
document.getElementById("ct1").innerHTML = ct_text;
</script>