title: Loop Between Array Values
body: <p>I have an array of numbers from 1 to 6.
  But my for loop is greater than this number.
  I want to make my array turn back to 1 when loop's max number is equal.
  So basically if max number is 10 it should count as 1,2,3,4,5,6,1,2,3,4.</p>
  
  <pre><code>var myFiles =  new Array(1,2,3,4,5,6);
  var filecount = myFiles.length;
  var layercount = 10;
  var f = 0;
  var n = 0;
  
  for(var m = 0; m &lt; layercount; m++,n++) { 
      if (m &gt; f) { 
          f = 0; 
          n = n - m; 
          f = f + n;
      }
      $.write (myFiles[f]);    
  }
  </code></pre>