my code is working in the console, but not when loading the website.
function getData() {
var a = [];
d3.csv("../csv/master.csv").get(function (error, rows) {
for (var i = 0; i < rows.length; i++) {
a.push(rows[i]);
}
});
return a;
}
a = getData();
alert(a[0].agency);
Strangely, the variable a seems to be loaded by the website as I can call it in the console, but the alert throws an error.
("Uncaught TypeError: Cannot read property 'agency' of undefined")
When I call the exact same alert in the console, however, it works perfectly.
Any ideas?
Thanks,
Jonas