title: Why do I only receive a single alert from the following javascript?
body: <p>This is a javascript function inside of a HTML  tag, however - when I move the alert(currentalbum) below the for loop, the second alert does not run - only the first, why?</p>
  
  <pre><code>function populatetracks(albumvalue) {
      var currentalbum = albumvalue;
      alert(currentalbum); // #1
  
      document.getElementById("TracksList").options.length = 0; 
  
      for(i = 0; albums[albumvalue].tracks.length - 1; i++) {
          var s = document.getElementById('TracksList');
          var opt = document.createElement('option');
          opt.appendChild( document.createTextNode(albums[albumvalue].tracks[i].title));
          opt.value = i;
          s.appendChild(opt);
      }
  
      alert(currentalbum); // #2
  }
  </code></pre>
  
  <p>'#1' does produce an alert, but '#2' doesn't.</p>