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 i=0; const waitFor = (ms) => { new Promise((r) => { setTimeout(function () { console.log('timeout completed: ',ms,' : ',i); i++; if(i==data.length){ console.log('Done') } }, ms); }) } var data=[1000, 200, 500]; data.forEach((num) => { waitFor(num) })