How do I prevent my program from overwriting localStorage every time a button is clicked?
<pre class="lang-js prettyprint-override"><code>document.getElementById("submit").addEventListener("click", getElements)

function getElements() {

  var a = document.getElementById("sample").value;
  var x = new obj(a);

  function store() {
    localStorage.setItem('todays-values', Object.values(x));
  }

  store();
}
</code></pre>

<p>In a separate js file I then call</p>

<pre><code>localStorage.getItem('todays-values');
</code></pre>

<p>I get the values, but if I put new inputs into my html file and click the submit button, the previous values get overwritten and replaced by the new ones. How do I store all the values that are submitted and prevent the old ones from getting replaced?</p>

<p>I'm very new to Javascript so I would prefer to solve this problem without the use of any additional libraries if possible. </p>