Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function gladiatorExpenses(lostFights, helmetPrice, swordPrice, shieldPrice, armorPrice) {
- let expenses = 0;
- let helmetCount = 0;
- let swordCount = 0;
- let shieldCount = 0;
- let armorCount = 0;
- for (let i = 1; i <= lostFights; i++) {
- if (i % 2 === 0) {
- helmetCount++;
- }
- if (i % 3 === 0) {
- swordCount++;
- }
- if (i % 3 === 0 && i % 2 === 0) {
- shieldCount++;
- if (shieldCount % 2 === 0) {
- armorCount++;
- }
- }
- }
- expenses = swordCount * swordPrice + helmetCount * helmetPrice + shieldCount * shieldPrice + armorCount * armorPrice;
- console.log(`Gladiator expenses: ${expenses.toFixed(2)} aureus`);
- }
Advertisement
Add Comment
Please, Sign In to add comment