Async Loops

by amindunited

JavaScript

const asyncLoops = (async () => {

	const myArray = [1, 2000, 300, 50, 600];
  
  return await Promise.all(myArray.map(async (val) => {

		await new Promise((resolve, reject) => {
      setTimeout(() => {
      	console.log('resolving', val);
      	resolve();
      }, val);
    })

  })).then(() => {
  	console.log('hrm...after');
  });
  
});

asyncLoops();