title: Pushing input value to array in local storage goes wrong
body: <p>For a project I'm working on I want to store a value from an inputfield in a array thats being stored in localstorage. By looking up older questions on here I've managed to get a long way already, but still something isn't going right. When I use console.log to check if my array is being filled after I've entered something, it shows a bunch of nested arrays in my console of which I don't know how to fix/work with. </p>
  
  <p>My js:</p>
  
  <pre><code>names = [];
  names.push(JSON.parse(localStorage.getItem('locname')));
  localStorage.setItem('locname', JSON.stringify(names));
  
  function saveData(data) {
  
    names = [];
    var data = document.getElementById("locationName").value;
    names = JSON.parse(localStorage.getItem('locname'));
    names.push(data);
    alert(names);
    localStorage.setItem('locname', JSON.stringify(names));
  }
  
  console.log(names);
  </code></pre>
  
  <p>In my HTML I have a input with id=locationName, and a button with onclick=saveData(). </p>
  
  <p>What am I doing wrong?</p>