JSFiddle - React, Tailwind, and code Playground
by Lardpower
JavaScript
const ids = [1,2,3,4,5];
async function setT(i){
return setTimeout(() => {console.log(i);}, i*1000);
}
async function main(){
let result = 0;
await Promise.all(ids.map(async (i) => {
await setT(i);
result += 100;
// do something else
console.log(result);
}));
return result;
}
async function internal(){
await main();
}
internal();