Advertisement
PowerCell46

Gladiator's expenses JS

Nov 11th, 2022
745
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function gladiatorExpenses(lostFightsCount, helmetPrice, swordPrice, shieldPrice, armorPrice) {
  2. brokenHelmetCount = 0;
  3. brokenSwordCount = 0;
  4. brokenShieldCount = 0;
  5. brokenArmorCount = 0;
  6.  
  7. for(currentLostBattle = 1; currentLostBattle <= lostFightsCount; currentLostBattle++) {
  8.  
  9. if(currentLostBattle % 2 === 0) {
  10. brokenHelmetCount++;
  11. }
  12.  
  13. if(currentLostBattle % 3 === 0) {
  14. brokenSwordCount++;
  15. }  
  16.  
  17. if(currentLostBattle % 2 === 0 && currentLostBattle % 3 === 0) {
  18. brokenShieldCount++;
  19.  
  20. if(brokenShieldCount % 2 === 0) {
  21. brokenArmorCount++;
  22. }}
  23.  
  24. }
  25.  
  26. let totalSum = brokenHelmetCount * helmetPrice + brokenSwordCount * swordPrice + brokenShieldCount * shieldPrice + brokenArmorCount * armorPrice;
  27. console.log(`Gladiator expenses: ${totalSum.toFixed(2)} aureus`);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement