JavaScript for loop Statement Example

Updated on     Kisan Patel

Loops is used to execute a block of statement a specified number of time or till a specified condition is true.

The for loop accepts three parameters; the initial value to start, condition till the loop should execute and increment the value.


for (initial condition; terminating condition; stepping condition)

Here is a JavaScript which makes use of for loop

<table border="1">

 <script type="text/javascript">
 for (i = 1; i <= 10; i++) {
      document.write("<tr><td>" + i + "</td><td>" + (i * i) + "</td></tr>");


See the Pen NqmaKz by Kisan (@pka246) on CodePen.


Leave a Reply