I've 3 functions in Javascript. function1 insert data into an array-array_message', function2 export the 'array_message' into a csv file. The function3 call these two functions with all the elements in a list.
In Javascript, function2 is executed at the same time as function1, which makes that the exported file is always empty because no time to fill in the 'array_message'.
Could anyone help how to call function2 when function1 is done in this 'for' loop? Maybe another callback function?
function function3(){
for (var i=0; i<list.length;i++){
console.log(list[i]);
function1(list[i])
function2(list[i]+'.csv',array_message)
}
}
function1needs to accept thatlist[i]item and produce thearray_messageobject, whichfunction2consumes afterwards, thus you can chain them more easily.