Software-Engineering
# Why do we use loops?
To do repetitive tasks multiple times (automatically).
Loop goes until condition gets false.
- break - interrupt loop.
- continue - skip item during iteration.
# Loops
# Interrupting & skipping Loops
break - interrupts a loop
continue - skip certain iteration
# Examples
# For Loop
when we know how many iterations we go.
# While Loop
when we don’t specifically know how many iterations we go.
# Do-While Loop
runs at least once if condition is true/false.
# For-of Loop
to iterate over an array/list … for every item.
# ForEach Loop
if we are interested in index of array. Can take 2 or 3 arguments: item, index, array.
# For-in Loop
if we want to get object with specific key.