Check out example codes for "ts await foreach loop". It will help you in understanding the concepts better.

Code Example 1

public async Task RunAsync()
{
    var tasks = new List<Task>();
 
    foreach (var x in new[] { 1, 2, 3 })
    {
        var task = DoSomethingAsync(x);
        tasks.Add(task);
    }
 
    await Task.WhenAll();
}

Code Example 2

for (const file of files) {
    const contents = await fs.readFile(file, 'utf8');
    console.log(contents);
  }

Code Example 3

async function printFiles () {
  const files = await getFilePaths();

  await Promise.all(files.map(async (file) => {
    const contents = await fs.readFile(file, 'utf8')
    console.log(contents)
  }));
}

Learn ReactJs, React Native from akashmittal.com