개념
<script>
/*
[연속 누적2 for문]
반복문을 사용해서 보기와 같이 출력하시오.
[보기]
0 0
2 2
4 6
6 12
8 20
*/
let total = 0;
let a = 0;
for(let i = 0; i < 5; i++) {
total += a;
document.write(a, " ", total, "<br>");
a += 2;
}
document.write("<br>");
let total2 = 0;
for(let i = 0; i < 10; i += 2) {
total2 += i;
document.write(i, " ", total2, "<br>");
}
</script>
HTML
복사


