title: Beginner JavaScript for loop
body: <p>I was wondering if anyone knows the reason for [i-1] in the fourth line when you also have i++ in the second line? Thank you for any help! (It's from the book "JavaScript" by Vodnik and Gosselin.)</p>
  
  <pre><code>if (figureCount === 3) {
  
  for (var i = 1; i &lt; 4; i++) {
  filename = "images/IMG_0" + photoOrder[i] + "sm.jpg";
  currentFig = document.getElementsByTagName("img")[i - 1];
  currentFig.src = filename;
  }//end of for loop
  </code></pre>