Im trying to populate four arrays with data from the ajax call but when I do a console.log I get a blank array. If I console log the data I get
var progress = new Array();
var test = new Array();
var done = new Array();
var todoArray = new Array();
function getTasks(todoArray){
$.ajax({
method: "GET",
url: "/tasks/"
})
.done(function(data) {
for(var i in data){
if (data[i].status == "todo") {
todoArray.push(data[i]);
}
else if(data[i].status == "in-progress"){
progress.push(data[i]);
}
else if(data[i].status == "to-test"){
todoArray.push(task);
}
else if(data[i].status == "done"){
done.push(data[i]);
}
}
});
console.log(todoArray);
}
getTasks(todoArray);