function testPromise(ms) { return new Promise(resolve => { setTimeout(function () { resolve(); }, ms); }); } var i=0 async function test() { while(i<20){ i++ await testPromise(3000); console.log(i); } } test()