title: Array Multiplying everytime adding an array in localstorage
body: <p>So I've made local storage that contains an array using JSON parse and stringify (&quot;more about it here&quot; <a href="https://stackoverflow.com/questions/3357553/how-do-i-store-an-array-in-localstorage">How to store an array in localstorage</a>)</p>
  <p>the code running well on the first run</p>
  <p>but in the next run, it's making multiple arrays</p>
  <p>maybe like this :
  1st run = 1 array</p>
  <p>2nd run = 2 array</p>
  <p>3rd run = 3 array</p>
  <p>and so</p>
  <p>My Code :</p>
  <pre><code>    function setbookmark(){
    const bokmark = document.getElementById(&quot;Bokmark&quot;)
  bokmark.style.display = &quot;block&quot;
  let bmkname = document.getElementById(&quot;name&quot;)
  bmkname.setAttribute(&quot;placeholder&quot;,document.getElementById(&quot;Welcomer&quot;).innerText)
  
  // close 
  document.querySelector(&quot;#Bokmark &gt; div.modal-dialog &gt; div.modal-content &gt; div.modal-header &gt; button.close&quot;).addEventListener('click', function (e) {
      bokmark.style.display = &quot;none&quot;
      })
  
      //yes
      document.querySelector(&quot;#Bokmark &gt; div.modal-dialog &gt; div.modal-content &gt; div.modal-footer &gt; button#yes&quot;).addEventListener('click', function (e) {
      bokmark.style.display = &quot;none&quot;
      
      const bmk = localStorage.getItem(&quot;bmk&quot;)
      if(bmk == null){
        localStorage.setItem(&quot;bmk&quot;, &quot;[]&quot;)
      }
  
      let old = JSON.parse(localStorage.getItem(&quot;bmk&quot;))
      if(bmkname.value == &quot;&quot;){
        title = document.getElementById(&quot;Welcomer&quot;).innerText
        old.push({url,title})
      }else{
        let title = bmkname.value
        old.push({url,title})
      }
      localStorage.setItem(&quot;bmk&quot;,JSON.stringify(old))
    })
    }
    const bmk = JSON.parse(localStorage.getItem(&quot;bmk&quot;))
  console.log(bmk)
  </code></pre>
  <p>I don't know what is wrong with that
  hopefully, you guys can help me</p>