Q:

wait for loop to finish javascript

async function processArray(array) {
  // map array to promises
  const promises = array.map(delayedLog);
  // wait until all promises are resolved
  await Promise.all(promises);
  console.log('Done!');
}
0
function doFirst() {
  return new Promise(function(resolve, reject) {
    //do a thing
      if (){
          return reject(value);
  	  }
      resolve(value);
    });
  });
}

async function doSecond() {
    var outputValue = await doFirst();
    console.log(outputValue);
}
0

New to Communities?

Join the community