As the title suggests. How do I do this?
I want to call whenAllDone() after the forEach-loop has gone through each element and done some asynchronous p
whenAllDone()
var counter = 0; var listArray = [0, 1, 2, 3, 4]; function callBack() { if (listArray.length === counter) { console.log('All Done') } }; listArray.forEach(function(element){ console.log(element); counter = counter + 1; callBack(); });