xxxxxxxxxx
async function printFiles () {
const files = await getFilePaths();
for (const file of files) {
const contents = await fs.readFile(file, 'utf8');
console.log(contents);
}
}
xxxxxxxxxx
const players = await this.getWinners();
// BAD
await players.forEach(async (player) => {
await givePrizeToPlayer(player);
});
await sendEmailToAdmin('All prizes awarded');
============================
Ideal way is
for (const player of players) {
await givePrizeToPlayer(player);
}
xxxxxxxxxx
const players = await this.getWinners();
// BAD
await players.forEach(async (player) => {
await givePrizeToPlayer(player);
});
await sendEmailToAdmin('All prizes awarded');
xxxxxxxxxx
const players = await this.getWinners();
// BAD
await players.forEach(async (player) => {
await givePrizeToPlayer(player);
});
await sendEmailToAdmin('All prizes awarded');
xxxxxxxxxx
const players = await this.getWinners();
// BAD
await players.forEach(async (player) => {
await givePrizeToPlayer(player);
});
await sendEmailToAdmin('All prizes awarded');
xxxxxxxxxx
const players = await this.getWinners();
// BAD
await players.forEach(async (player) => {
await givePrizeToPlayer(player);
});
await sendEmailToAdmin('All prizes awarded');
xxxxxxxxxx
const players = await this.getWinners();
// BAD
await players.forEach(async (player) => {
await givePrizeToPlayer(player);
});
await sendEmailToAdmin('All prizes awarded');
xxxxxxxxxx
const players = await this.getWinners();
// BAD
await players.forEach(async (player) => {
await givePrizeToPlayer(player);
});
await sendEmailToAdmin('All prizes awarded');
xxxxxxxxxx
const players = await this.getWinners();
// BAD
await players.forEach(async (player) => {
await givePrizeToPlayer(player);
});
await sendEmailToAdmin('All prizes awarded');