title: how to create an element in a loop and append it (5 times one by one) to the particular div?
body: <p>I<code>m trying to create an element(image) and then set a loop that would produce 5 images in one div(its id="leftSide"). Here</code>s my code:</p>
  
  <pre><code>&lt;script&gt;    
      var number_of_faces = 0;
      var theLeftSide = document.getElementById("leftSide");
  
      function generate_faces() {
          for (number_of_faces = 0; number_of_faces &lt; 6; number_of_faces++) {
              newFace = document.createElement("img");
              newFace.setAttribute(
                "src",
                "http://home.cse.ust.hk/~rossiter/mooc/matching_game/smile.png"
              );
              document.getElementById("leftSide").appendChild("img");
          }   
     }
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Body onload has to call the function, but nothing happens. Div remains "empty"</p>