title: How to display image using javascript
body: <p>How to display an image as many times as input(number) given by the user in html using javascript? There seem to be an error in my code,dont know how to rectify.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;p&gt;Click the button to add a new element to the array.&lt;/p&gt;
  &lt;input type="number" id="myNumber" value=""&gt;
  &lt;button onclick="imag(c,x)"&gt;Try it&lt;/button&gt;
  
  
  &lt;p id="demo"&gt;&lt;/p&gt;
  
  &lt;script&gt;
  function imag(c,x) {
  var x = document.getElementById("myNumber").value;
  var c="&lt;img src='C:/Users/Akhil/Desktop/New folder/G.jpg'/&gt;";
      
    var arr = [];
    for (var i = 0; i &lt; x; i++) {
      arr.push(c);
    
    document.getElementById("demo").innerHTML = arr;
  
  }
  }
  
  
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>