for문
반복횟수를 '명확히 알고 있을 때' 주로 사용
for (초기화식begin; 조건식condition; 증감식step) {
// 코드
// 실행문. '반복문 본문(body)'이라 불림
}
while문
'조건에 따라 반복횟수를 결정해야 할 때' 주로 사용
<-> do-while문은 조건을 먼저 검사하느냐, 나중에 검사하느냐의 차이!
while (condition) {
// 반복문 본문
}
do {
// 반복문 본문
} while (condition);
둘중에서는 for문을 가장 많이 사용함
∵ for문이 while문보다 좀 더 가독성이 좋고 사용하기 편함
참고출처
https://coding-factory.tistory.com/382#google_vignette
https://ko.javascript.info/while-for