Well done! Loops are commonly used in programming because they save time, reduce error, and are easy to read. Being comfortable with each type of loop will make you a better programmer. In review:
- A loop is a structure in programming where the instructions are written once, but a computer can execute them multiple times
- Each execution of those instructions is called an iteration
- For loops (count-controlled loops) repeat for a specified number of times
- While loops (condition-controlled loops) repeat until a condition changes
- For each loops (collection-controlled loops) repeat for each item in a collection
Make sure you’re comfortable with the above concepts before moving on!
Sign up to start coding