title: getting a value from a callback function
body: <p>I'm trying to return a value from a callback function and assign it to a variable, though am struggling to work it out - any help would be really appreciated....</p>
  
  <pre><code>var latlng1;
  
  function getLocation(){
    navigator.geolocation.getCurrentPosition (function (position){
      coords = position.coords.latitude + "," + position.coords.longitude;
      callback();         
    })
  }
  
  //how can I assign the coords value from the callback to variable latlng1 with global scope?
  getLocation (function(){
    //alert(coords);
    return coords;
  })
  
  // -----------
  //I'm trying something like this....but no joy
  latlng1 = getLocation (function(){
    return coords;
  }
  </code></pre>