I have gone through link: variable scope in d3 javascript as my data was not getting loaded in the variable at first.
I tried the following code:
let train;
// d3.csv("training.csv", function(data){train = data;});
function myFunc(data) {
train = data;
}
d3.csv("training.csv", function (data) {
var csv = data;
myFunc(csv);
});
Still I am getting the variable as undefined
when I tried to log it through console.log()
See the following image:
Please let me know what I can do. Have I been missing something? Please suggest me what I can do to avoid this issue.