Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(lostFightCount, helmetPrice, swordPrice, shieldPrice, armorPrice) {
- let sum = 0;
- let counter = 0;
- for (let i = 1; i <= lostFightCount; i++) {
- if (i % 2 === 0 && i % 3 !== 0) {
- sum += helmetPrice;
- } else if (i % 3 === 0 && i % 2 !== 0) {
- sum += swordPrice;
- } else if (i % 2 === 0 && i % 3 === 0) {
- sum += helmetPrice;
- sum += swordPrice;
- sum += shieldPrice;
- counter++;
- } else if (counter === 2) {
- sum += armorPrice;
- counter = 0;
- }
- }
- console.log(`Gladiator expenses: ${sum} aureus`);
- }
- console.log(solve(
- 7,
- 2,
- 3,
- 4,
- 5
- ));
Advertisement
Add Comment
Please, Sign In to add comment