Posted in All Posts, Semester 2

JavaScript Basics – Iterations (Loops)

We will see how Iterations, generally called as loops are used in JS.
There’s no comparison between the loops. Each have their own use and are to be used upon your need and preference.
Below is a program to print numbers from 1 to 5 using the three loops for you to see their working.

Do-While Loop

Try It Yourself

While Loop

Try It Yourself

For Loop

Try It Yourself

We hope that you found this article to be helpful.
Please share your thoughts in the Comments Section.

If you liked this article, then please like our Facebook page.

Suggested Reading

Comment your thoughts