var rootRef = firebase.database().ref().child('Locations');
    rootRef.on("value", function(snapshot) {
             lat = snapshot.child('latitude').val();
             longi = snapshot.child('longitude').val();
             console.log(snapshot.child('latitude').val());
          }, function (error) {
             console.log("Error: " + error.code);
   });
When i console.log(lat); lat is undefined. I am new to javascript. Is there any way it can be globally available?
 
     
    