Execute for loop forward and backward - Javascript Statement

Javascript examples for Statement:for

Description

Execute for loop forward and backward

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {//  www.j a va2s.co m
 function log(str) {
    document.write(str+"<br />");
}
var index, max = 25;
for (var i = 0; i < max; i++) {
   if (parseInt(i / 5) % 2)
     index = parseInt(i/5)*5 + 4 - i % 5;
   else
     index = i;
   log(index);
}
    });

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials