Week 4 Day 3
New Terms
- For Loop
- While Loop
- Do While Loop
For Loop
The for loop is one of the most commonly used looping structures in JavaScript. It provides a concise way to iterate over a range of values. This loop consists of three main parts: initialization, condition, and increment.
While Loop
The while loop offers a different approach by executing a block of code as long as a specified condition remains true. This loop is particularly useful when the number of iterations isn’t predetermined, and the loop needs to continue until a certain condition is met.
Do While Loop
The do while loop is similar to the while loop, but with one key distinction: it guarantees that the code block will execute at least once, regardless of the condition. This loop first executes the code and then checks the condition, making it ideal for scenarios where the initial execution is necessary before validating any conditions.