messageRef1.on("child_added", function(snap) {
console.log(snap.val());
mylat=snap.val();
})
document.write(mylat);
the console prints out the correct data and i could even use document.write within that function, but im unable to use the data anywhere else in the code. I understand this probably because firebase works asynchronously and basically the rest of the code doesnt wait for firebase. i saw this How can i access firebase variable outside firebase function but i dont understand how i could simply implement something here. thanks