ErolKZ

Untitled

Sep 24th, 2021
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1.  
  2. function solve(lostFightCount, helmetPrice, swordPrice, shieldPrice, armorPrice) {
  3.  
  4.  
  5. let sum = 0;
  6.  
  7. let counter = 0;
  8.  
  9.  
  10. for (let i = 1; i <= lostFightCount; i++) {
  11.  
  12. if (i % 2 === 0 && i % 3 !== 0) {
  13.  
  14. sum += helmetPrice;
  15.  
  16. } else if (i % 3 === 0 && i % 2 !== 0) {
  17.  
  18. sum += swordPrice;
  19.  
  20. } else if (i % 2 === 0 && i % 3 === 0) {
  21.  
  22. sum += helmetPrice;
  23.  
  24. sum += swordPrice;
  25.  
  26. sum += shieldPrice;
  27.  
  28. counter++;
  29.  
  30. } else if (counter === 2) {
  31.  
  32. sum += armorPrice;
  33.  
  34. counter = 0;
  35.  
  36. }
  37.  
  38.  
  39. }
  40.  
  41.  
  42.  
  43. console.log(`Gladiator expenses: ${sum} aureus`);
  44.  
  45. }
  46.  
  47.  
  48. console.log(solve(
  49.  
  50. 7,
  51.  
  52. 2,
  53.  
  54. 3,
  55.  
  56. 4,
  57.  
  58. 5
  59.  
  60. ));
Advertisement
Add Comment
Please, Sign In to add comment