title: Cannot read property 'id' of null - JS error
body: <p>I have the following html code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
      var array = ["one", "two", "three", "four"];
      for(i = 0; i&lt;array.length; i++){
          alert(array[i]);
          var tmp = document.getElementById(array[i]);
          alert(tmp.id);
          alert(tmp.innerHTML);
          var to_append = tmp.innerHTML;
          array_inc.push(to_append);
          alert(array_inc);
          console.log(array_inc);
      }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id = "one"&gt;1&lt;/div&gt;
      &lt;div id = "two"&gt;2&lt;/div&gt;
      &lt;div id = "three"&gt;3&lt;/div&gt;
      &lt;div id = "four"&gt;4&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Yet in the console, I'm receiving an error when it reaches line 9 when it says "type of null does not exist", but clearly the id of the div must exist because I had it declared as an id in the body. How is this possible?</p>