TZinovieva

Gladiators Expenses

Jan 19th, 2023
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function gladiatorExpenses(lostFights, helmetPrice, swordPrice, shieldPrice, armorPrice) {
  2.     let expenses = 0;
  3.     let helmetCount = 0;
  4.     let swordCount = 0;
  5.     let shieldCount = 0;
  6.     let armorCount = 0;
  7.     for (let i = 1; i <= lostFights; i++) {
  8.  
  9.         if (i % 2 === 0) {
  10.             helmetCount++;
  11.         }
  12.         if (i % 3 === 0) {
  13.             swordCount++;
  14.         }
  15.         if (i % 3 === 0 && i % 2 === 0) {
  16.             shieldCount++;
  17.             if (shieldCount % 2 === 0) {
  18.             armorCount++;
  19.             }
  20.         }
  21.     }
  22.     expenses = swordCount * swordPrice + helmetCount * helmetPrice + shieldCount * shieldPrice + armorCount * armorPrice;
  23.     console.log(`Gladiator expenses: ${expenses.toFixed(2)} aureus`);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment