javascript - How can I set a variable inside a loop without messing up the loop? -
i'm quite new this, sorry if daft question. have searched answer can't find close enough solution adapt. part of code:
for (var k = 0; k < (pointstoshow.length-1); k++){ // k looping nicely @ point u = pointstoshow[k] //k not looping @ point, uses last number allpoints[u].setmap(map); }
i trying access numbers inside array (pointstoshow) use number stored reference search array (allpoints), can't work. if set alert show pointstoshow[k] works fine, it's once try , attach them variable doesn't work.
i've been working on of today no joy, suggestions appreciated.
thanks
you missed semi-colon , need declare u. not entirely sure needs happen here shot in dark.
var u; for(var k = 0; k < (pointstoshow.length-1); k++){ u = pointstoshow[k]; allpoints[u].setmap(map); }
Comments
Post a Comment