title: I made a mistake in a simple JS program, but I don't know why it's wrong
body: <p>The program is supposed to take string and print it's reverse in the console:</p>
  
  <pre><code>var string = "squirrels";
  reverseString = "";
  for (var i = 0; i &lt; string.length; i++) {
  reverseString[i] = string[string.length - 1 - i];
  }
  console.log(reverseString);
  </code></pre>
  
  <p>If instead I declare reverse as an empty array, and instead use </p>
  
  <pre><code>console.log(reverseString.join(""));
  </code></pre>
  
  <p>then the code works fine - but whats wrong with the original code?</p>