title: Function after checking for Geolocation doesn't start
body: <p>I'm building a small web app that takes a form input (name) + the geolocation of the user and puts this in localstorage arrays. I'm new to JS, but I've already got the part that takes care of the name complete. I'm now trying to expand it to the point where the Latitude + Longitude get stored in a localstorage array at the moment when a user presses submit, but somehow the function that does this won't start/set through. </p>
  
  <pre><code>window.onload = function() {
  
  // Read value from storage, or empty array
  var names = JSON.parse(localStorage.getItem('locname') || "[]");
  var lat = JSON.parse(localStorage.getItem('latitude') || "[]");
  var long = JSON.parse(localStorage.getItem('longitude') || "[]");
  
  function initCoords() {
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(saveData);
      console.log('This works');
    } else {
      showError("Your browser does not support Geolocation!");
    }
  }
  
  function saveData(data){
    console.log('But does it get here?');
    //Push Users Input value
    var data = document.getElementById("locationName").value;
    names.push(data);
    localStorage.setItem('locname', JSON.stringify(names));
  
    //Push Latitude
    var latitude = position.coords.latitude;
    lat.push(latitude);
    localStorage.setItem('latitude', JSON.stringify(latitude));
  
    //Push Longitude
    var longitude = position.coords.longitude;
    long.push(longitude);
    localStorage.setItem('longitude', JSON.stringify(longitude));
    }
  
  document.querySelector('#saveData').onclick = initCoords;
  } 
  </code></pre>
  
  <p>I have a button with the id saveData. My earlier version of this script without geolocation worked perfectly, there I started the saveData function by clicking the button. In this case I first wanted to check if the user had geolocation available, therefor i created the initCoords function.</p>
  
  <p>I tried to use console log to see where my function ends, it somehow doesnt get to the 'But does it get here' in saveData. </p>