Loops Flashcards

1
Q

What abilities does loops gives you ?

A

They give you the ability to execute the same code block over and over which keeps your code smaller and more readable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How many types are there in loop ?

A

1: For loop
2: While loop
3: Do while loops
4: For in loop
Then there’s
-Break

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

1: For loop
How many parts does it have ?
What’s the syntax

A

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.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly