title: JavaScript iterate loop every x number of times in same loop?
body: <p>I am not sure how to phrase this, so please re-title this question if it doesn't make sense. Anyways, this is what I am trying to do.</p>
  
  <p>I have a variable with the length of 9.
  And then I have another variable with the length of 3.</p>
  
  <p>How do I write a loop that iterates through all 9 but starts over every third time?</p>
  
  <p><strong>For example: I have this,</strong></p>
  
  <pre><code>x = 3;
  l = 9;
  
  for ( var i = 0; i &lt; l; i++)
  { 
       console.log(i + 1);
  }
  
  output = 1,2,3,4,5,6,7,8,9
  </code></pre>
  
  <p><strong>The output I want to create</strong></p>
  
  <pre><code>output = 1,2,3,1,2,3,1,2,3
  </code></pre>
  
  <p>I was thinking there might be away to do this with an if statement or possibly modulus, but wasn't quite sure how to implement it. What would be a good way to do this? Thanks in advance.</p>