Fixing Javascript Loop

Need to access the position in the for loop.