title: Creating div element with a for Loop
body: <p>This is a really simple question but I don't know why it doesn't work. I have an array with 4 items inside. And I have a container which I would like to insert a number of divs based on the number of items in my array. I used a for loop for this but it is only creating one div. Should it not create 4 of the same div elements? </p>
  
  <p>This is the code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>count = new Array['1', '2', '3', '4'];
  container = document.getElementById('items');
  
  for (i = 0; i &lt; count.length; i++) {
    container.innerHTML += '&lt;div id="items"&gt;&lt;/div&gt;';
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#items {
    width: 20px;
    height: 20px;
    background: gold;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="items"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is the link  <strong><a href="http://codepen.io/2bu/pen/jyxNbw" rel="nofollow noreferrer">http://codepen.io/2bu/pen/jyxNbw</a></strong></p>