i havent written in js in awhile and am a bit rusty apparently. trying to understand the following problem. the alert in getCurrentPosition successCallback shows the latitude correctly, but the last line alerts undefined. why isnt my client_location function returning the latitude when call outside the function?
client_location = function() {
if (navigator.geolocation) {
return navigator.geolocation.getCurrentPosition(function(position) {
alert(position.coords.latitude); ## RETURNS LATITUDE CORRECTLY ##
return position.coords.latitude;
});
}
};
alert(client_location()); ## RETURNS UNDEFINED ##