JavaScript For Loop Example

JavaScript for loop check condition and executes block of code for a specific number of times, until specified condition argument become false.


<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <title>JavaScript for loop</title>
<pre>  <!-- Use pre element for work document.writeln() method -->
  for( var num = 1; num <= 10; num++ ){
      document.writeln(num + ": iteration");
  document.writeln("End of for loop");

Run it...   »

Example Result