What is the formula for damage per round?

I’m crating a web app to learn JS that will calculate damage per round but I’m stuck on adding criticals.

I have successfully created variables for: diceNumber, diceSides, bonuses, attacksPerRound, and criticalChance

What is the formula to add all of these together to get the average damage per round?