0
Q:

async foreach

async function asyncForEach(array, callback) {
  for (let index = 0; index < array.length; index++) {
    await callback(array[index], index, array);
  }
}

asyncForEach([1, 2, 3], async (num) => {
  await waitFor(50);
  console.log(num);
})
2
  for (const file of files) {
    const contents = await fs.readFile(file, 'utf8');
    console.log(contents);
  }
 
3
[1, 2, 3].forEach(async (num) => {  await waitFor(50);  console.log(num);});console.log('Done');
0

New to Communities?

Join the community