Here is the code from the codepen
Not sure why the “lat” variable is not updated after I call the API…
$(document).ready(function(){
var api ="http://api.openweathermap.org/data/2.5/weather?q=London&APPID=5509e4d3e24ba333ea491217acad1d3d";
var lat = "lat_initial";
$.getJSON(api, function(data){
alert("JSON OBTAINED!");
lat = data.coord.lat;
});
$(".getLatBtn").on("click", function(){
alert("BUTTON PUSHED!");
$(".latitude").text(lat);
});