Reading_Notes

View the Project on GitHub Hiba-Almade/Reading_Notes

LOOP with JS

Loops are used in JavaScript to perform repeated tasks based on a condition. Conditions typically return true or false when analysed. A loop will continue running until the defined condition returns false.

oops are handy, if you want to run the same code over and over again, each time with a different value.

There are many different kinds of loops

For loop:

Probably the most common type of loop, for loops, are great for when you already know how many times you want to loop through something. When using a for loop, we typically use a counter that will either increment or decrement until a condition is met. Once the condition is met, the loop will stop. for loop

While loop:

A while loop is slightly different than a for loop for the fact that it’s good to use when we don’t know how many times we want to loop through a problem beforehand. This is the key difference between using a for loop or a while loop. while loop


On the other hand, we may need to merge more than one condition together, so we use logical operators:

Comparison operators compare two values and give back a boolean value: either true or false. Comparison operators are used in decision making and loops. logic