function getLinkList() {
var linkList = [];
$.getJSON("http://api.teleport.org/api/urban_areas/", function(json) {
for (var i = 0; i < json['count']; i++) {
linkList.push(json['_links']['ua:item'][i]['href']);
}
});
return linkList;
}
var x = getLinkList();
console.log(x);
console.log(x[2]);
so the first console.log displays my entire array properly, but the second one shows as 'undefined'. This does not make sense to me as x seems to store the array.