elibraryportal Logo

JS Loop

Loops can be execute a block of code a number of times.

Types of Loop

There are 4 types of loops in JavaScript that is.

  1. for loop
  2. while loop
  3. do-while loop
  4. for-in loop

1) For loop in JavaScript

In for loop is used to repeat the execution of the statements until a certain condition holds.


Flow Chart :-

For Loop of Java


Test it Now

2) while loop in JavaScript

In while loop check the condition is true,the code inside the while loop is executed.when the condition is false the loop will be stops


Example:- Print Fibonacci series

Test it Now

3) do-while loop JavaScript

In do while loop body of the loop is executed(Check) at first. Then the condition is evaluated. If the condition evaluates is true, the body of the loop inside the do statement is executed again.this process continues until the condition evaluates is to be false. Then the loop stops.


Example:- Print Even numbers

Test it Now
Next Topic