What's the advantage of using a for
loop over a while
loop?
for
loop repeats is easy to find inside the parenthesesfor
loop prevents infinite loopsfor
loop over a while
loopfor
loop has a code block and a while
loop doesn'tThe number of times a for
loop repeats is easy to find inside the parentheses.