I have a function that accepts a game found from a mongodb database via mongoose and the number of bots to add to the game object. the problem is after running the function only one bot object is being saved to the document even thought numOfBots
is 3
async function addBot(game, numOfBots){
for(index = 0; index < numOfBots; index++){
let bot = {nickName: "Bot"}
game.players.push(bot)
game = await game.save()
}
return game
}
// elsewhere in another async function
await addBot(game,3)
How can I use async await correctly in a regular for loop?