title: Resetting the iterator in a for...in loop
body: <p>This is part of the code I am using to draw some random circles:</p>
  
  <pre><code>if(circles.length != 0) { //1+ circles have already been drawn
    x = genX(radius);
    y = genY(radius);
    var i = 0;
    iCantThinkOfAGoodLabelName:
    for(i in circles) {
      var thisCircle = circles[i];
      if(Math.abs(x-thisCircle["x"])+Math.abs(y-thisCircle["y"])&gt;radius*2) {
        //overlaps
      } else {
        //overlaps
        x = genX(radius);
        y = genY(radius);
        continue iCantThinkOfAGoodLabelName;
      }
  
      if(i == circles.length - 1) { //Last iteration
        //Draw circle, add to array
      }
    }
  }
  </code></pre>
  
  <p>The problem is that when there is an overlap, the circle with the newly generated coordinates is not checked for overlap with the circles that the overlapping circle had already been checked with. I have tried setting i to 0 before using the continue statement but that did not work. Please help, I am really confused.</p>