Why are my variables not declaring outside a function

Why are my variables not declaring outside a function
0.0 0

#1

What im trying to do here is get the coordinates data from the html5 geolocation feature and declaring them to variables so that i can manipulate them. but for some reason when i go outside the function the values are undefined. Got any ideas on how I can combat this???help


#3

The getCurrentPosition API call is made asynchronously, so even though lat an long are declared globally outside your function, the console.log statements are executed before a response comes back from the getCurrentPosition API.