title: My global variable comes back as undefined (JavaScript)
body: <p>I'm really struggling with basic Javascript here... basically, I'm trying to make a function that, when called, sets two variables (longitude and latitude) so that I can run other functions straight afterwards that uses these values.</p>
  
  <p>When I try to alert out the longitude value however, it comes back undefined.</p>
  
  <p>Here's my code.</p>
  
  <pre><code>var latitude;    
  var longitude;
  
  function getLocation() {
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(displayLocation);
    } else {
      alert("Geolocation is not supported by this browser.");
    }
  }
  
  function displayLocation(position, latitude, longitude) {
    latitude = position.coords.latitude;
    longitude = position.coords.longitude;
    return;
  }
  
  function newLocation(longitude) {
    alert(longitude);
  }
  
  window.onload = function() {
    getLocation(); 
    newLocation();
  }
  </code></pre>
  
  <p>Any help will be seriously appreciated! Thanks.</p>