title: Why I cannot display all array objects using JS
body: <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>const demo = document.querySelector('.demo');
  const persons = [
      {name: "Abhishek", age: 20, weight: "52kg"},
      {name: "Akash", age: 21, weight: "70kg"},
      {name: "Ankit", age: 20, weight: "68kg"},
      {name: "Shubham", age: 19, weight: "60kg"},
      {name: "Harsh", age: 19, weight: "80kg"},
  ];
  
  persons.forEach(function(person) {
      const data = JSON.stringify(person);
      demo.innerHTML = data;
  })</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
      &lt;link href="./style/style.css" rel="stylesheet"&gt;
      &lt;title&gt;Document&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;Learning Javascript&lt;/h1&gt;
      &lt;div class="demo"&gt;&lt;/div&gt;
      &lt;script src="main.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>I wrote this code in order to display all objects inside my array but only the last object is visible. I used JSON.stringify() to convert my object to a string. Just explain me the reason behind this flaw.</p>