JSFiddle - React, Tailwind, and code Playground
by Sahin Deniz
JavaScript 1.7
let A = function(n){
return new Promise((resolve, reject)=>{
setTimeout(()=>{
resolve(n);
},2000);
});
}
let init= async (n)=>{
let b=await A(n);
console.log(b);
};
let count = 0;
let loop = setInterval(async ()=>{
if(++count == 5){
clearInterval(loop);
}
console.log("initStart");
if(false){
let b=await A(count);
console.log(b);
}else{
init(count);
}
console.log("initEnd");
},1000);