Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 1.41 KB

File metadata and controls

21 lines (14 loc) · 1.41 KB

🔑 For Loop

For loop is almost the same as while loop but it's much simpler.

Earlier, we had tried printing 'I Love WebLaunch!' for 100 times using while loop, now, let's try using for loop to do the same thing!

for (let count = 1; count <=100; count ++){
    console.log('I love WebLaunch!');
}

ℹ️ Initiate count to 1 and then set the condition to count <=100, meaning the loop will iterate as long as the count is less than or equal to 100. count ++ means the count will increase after each iteration.


In for loop, we initiate the counter, count condition and count increment in the parenthesis ( )after for .





◀️ Previous Page : Loops : While Loop 🔑                                           🏡                                           ▶️ Next Page : Control Flow : Object 🚩 🔓