for loop for iterating over a sequence or a set number of steps, and the while loop for repeating code as long as a condition remains true. Both are concise to write and easy to read.
The For Loop
Thefor loop runs a block of code until it reaches the end of a given sequence. In Standard, that sequence can be a single integer — causing the block to execute that exact number of times — or an array of objects to iterate over. Use @ inside the loop body to reference the current working object.
Print the loop index five times:
The While Loop
Thewhile loop runs a block of code repeatedly until the condition you provide evaluates to false. Make sure the condition can eventually become false to avoid an infinite loop.