Loops Flashcards
What abilities does loops gives you ?
They give you the ability to execute the same code block over and over which keeps your code smaller and more readable
How many types are there in loop ?
1: For loop
2: While loop
3: Do while loops
4: For in loop
Then there’s
-Break
1: For loop
How many parts does it have ?
What’s the syntax
It contain three major parts
1: initial value (this is the value assigned to the variable that will keep track of the progression in the loop, usually called i )
2: condition (this conditional that will get re-evaluated to check if the code inside the loop should run again )
3: iteration (This is how you advance in progress every time you complete one loop )
for ( let i = 1; i <=10; i++) { Console.log(i) }
“Start i at 1, log it to our console, increase the the value of i, then check that we’re still equal to or less than 10, if so, repeat.Once the value of i reaches 11, we can stop looping since 11 is greater than 10.”