title: Read array values in a loop in JavaScript
body: <p>I have an array in JavaScript that have defined these values:</p>
  
  <pre><code>var myStringArray = ["1","2","3","4","5","6","7","8","9","10"];
  </code></pre>
  
  <p>And when I call a function the first time function, I need to get this:</p>
  
  <pre><code>1
  2
  3
  </code></pre>
  
  <p>Calling it again I need to get:</p>
  
  <pre><code>4
  5
  6
  </code></pre>
  
  <p>Calling it again:</p>
  
  <pre><code>7
  8
  9
  </code></pre>
  
  <p>Calling it again:</p>
  
  <pre><code>10
  1
  2
  </code></pre>
  
  <p>Calling again:</p>
  
  <pre><code>3
  4
  5
  </code></pre>
  
  <p>And so on. You got the point, showing 3 values from the array and if we are at the end of array, read from the beginning... I have an app that has remote control and has down and up keys. When the user presses the down button to get these values from an array as described in the above example, if the user presses the up button it needs to go back from an example...so reading the array in a loop (at end, the array is read from the beginning, but always shows three values).</p>
  
  <p>I try using this:</p>
  
  <pre><code>var myStringArray = ["1","2","3","4","5","6","7","8","9","10"];
  var arrayLength = myStringArray.length;
  for (var i = 0; i &lt; arrayLength; i++) {
      if (i&lt;(6)) {
         console.log(myStringArray[i]);
      }
  }
  </code></pre>
  
  <p>But the next time I call this code, it shows from the beginning values of the array, not continue to read others value...do I need a second counter?</p>