zoqaapps.blogg.se

For of loop javascript
For of loop javascript












for of loop javascript

The condition (this comprises of the initialization, condition and updater).If we did not use the loop we would have to repeatedly write out the code we want to run and this would break a key principle of writing code called don’t repeat yourself - sometimes shortened to DRY. We may want to run some code multiple times until we reach a specific value such as counting up to 10. The three most common types of loops in javascript are the for loop, while loop and the do while loop.Ī for loop is useful to run some code when we know how many times that we want the loop to run. This would be an example of repeating a sequence until you reach a condition.īack in the programming world, you may come across the term to iterate over something such as an array. If you go out for a walk and want to reach your ten thousand steps for the day, then repeatedly you take steps until you reach ten thousand of them.

for of loop javascript

We use a loop when we have some logic which we need to happen repeatedly. Loops let us repeat some code over and over until a condition is met.














For of loop javascript