title: How can I set a variable inside a loop without messing up the loop?
body: <p>I'm quite new to this, so sorry if this is a daft question.  I have searched for the answer but I can't find a close enough solution to adapt.  This is part of my code:</p>
  
  <pre><code>for (var k = 0; k &lt; (pointstoshow.length-1); k++){
     // k looping nicely at this point
  u = pointstoshow[k]
     //k not looping at this point, only uses the last number
  allpoints[u].setMap(map);
  }
  </code></pre>
  
  <p>I am trying to access the numbers inside an array (pointstoshow) to use the number stored as a reference to search another array (allpoints), but I can't get it to work.  If I set an alert to show pointstoshow[k] it works fine, it's only once I try and attach them to a variable it doesn't work.</p>
  
  <p>I've been working on this most of today with no joy, so any suggestions appreciated.</p>
  
  <p>Thanks</p>