This problem is probably very easy to solve. I just can't seem to solve it. I currently have two functions, and I have to get the data out to the global object, but due to the syntax I'm unfamiliar with how to extract it. The following returns the value I'm looking for.
function position(func) {
return window.navigator.geolocation.getCurrentPosition(func);
}
position(pos => {
console.log(pos.coords.latitude);
});
What I need to do is get this out to the global scope. One of my many attempts is the following, which shows up as undefined
.
function position(func) {
return window.navigator.geolocation.getCurrentPosition(func);
}
let lat;
position(pos => {
lat = pos.coords.latitude;
});
console.log(lat);
Any help would be greatly appreciated.