I can't work out why console.log(latitude) isn't working outside of the if statement. I can recall latitude in the console so its value is being updated. My guess then is that console.log(latitude) is being run before latitude's value is changed but my solutions to ensure the if statement finishes first so far haven't worked. I've tried debugger too. Any help is much appreciated! (I hope I haven't overlooked something very simple!)
var latitude = "" ;
var longitude = "";
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      latitude = position.coords.latitude;
      longitude = position.coords.longitude;
      place.textContent = ("latitude: " + latitude + "  longitude: " + longitude);
    });
  }
  console.log(latitude);
 
    