title: Save and update array to local storage JS
body: <p>I am trying to send an array to local storage, when i click on the button and input has a value,  element is sended to the array in local storage like this:</p>
  
  <pre><code>["info before reloading 1","info before reloading 2","info before reloading 3"]
  </code></pre>
  
  <p>if I reload the page and write something in the input, all elements in array are deleted, and a new array is created with the new info i am typing like this</p>
  
  <pre><code>["new info 1","new info 2","new info 3"]
  </code></pre>
  
  <p>how could I do avoid initial info to be deleted , and the array just update and save in local storage like this</p>
  
  <pre><code> ["info before reloading 1","info before reloading 2","info before reloading 3", "new info 1","new info 2","new info 3"];
  </code></pre>
  
  <p>Thanks for your help </p>
  
  <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>var mydiv = document.querySelectorAll(".div_btn");
  console.log(mydiv);
  
  for(i=0; i&lt;mydiv.length; i++){
     mydiv[i].addEventListener("click", function(){
        var parent = this.parentElement;
        console.log(parent.firstElementChild.innerHTML);
     });
  }
  
  
  var btn_local = document.getElementById("btn_local");
  var user_name = document.getElementById("user_name");
  
  var mi_array = []; 
  
  btn_local.addEventListener("click", function(){
    var name_value =  user_name.value;
    if(name_value !== ""){
  
     mi_array.push(name_value);
     console.log(mi_array);
  
     var json_transform = JSON.stringify(mi_array);
     localStorage.setItem("usuarios", json_transform);
    }
  })</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;input type="text" id="user_name" placeholder="ingrese su nombre"&gt;
      &lt;button id="btn_local"&gt;Send array to local host&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>