SHOW:
|
|
- or go back to the newest paste.
| 1 | function GladiatorExpenses( | |
| 2 | lostFights, | |
| 3 | helmetPrice, | |
| 4 | swordPrice, | |
| 5 | shiledPrice, | |
| 6 | armorPrice | |
| 7 | ) {
| |
| 8 | let totalExpenses = 0; | |
| 9 | ||
| 10 | for (let currFight = 1; currFight <= lostFights; currFight++) {
| |
| 11 | if (currFight % 2 === 0) {
| |
| 12 | totalExpenses += helmetPrice; | |
| 13 | } | |
| 14 | ||
| 15 | if (currFight % 3 === 0) {
| |
| 16 | totalExpenses += swordPrice; | |
| 17 | } | |
| 18 | ||
| 19 | if (currFight % 6 === 0) {
| |
| 20 | totalExpenses += shiledPrice; | |
| 21 | } | |
| 22 | ||
| 23 | if (currFight % 12 === 0) {
| |
| 24 | totalExpenses += armorPrice; | |
| 25 | } | |
| 26 | } | |
| 27 | console.log(`Gladiator expenses: ${totalExpenses.toFixed(2)} aureus`);
| |
| 28 | } | |
| 29 | ||
| 30 | GladiatorExpenses(12, 2, 3, 4, 5); | |
| 31 |