Ivankooo1

Gladiator Expenses

Aug 14th, 2019
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. function Gladiator(losts,helmetPrice,swordPrice,shieldPrice,armorPrice){
  2. let helmetCount = 0;
  3. let swordCount = 0;
  4. let shieldCount = 0
  5. let armorCount = 0;
  6.  
  7. let price = 0;
  8. let price1 = 0;
  9. let price2 = 0;
  10. let price3 = 0;
  11. let price4 = 0;
  12.  
  13. for(let i = 1;i <= losts;i++){
  14.  
  15. if(i % 2 === 0){
  16. helmetCount++;
  17. price1 = helmetCount * helmetPrice;
  18. }
  19. if(i % 3 === 0){
  20. swordCount++;
  21. price2 = swordCount * swordPrice;
  22. }
  23. if(i % 2 === 0 && i % 3 === 0){
  24. shieldCount++;
  25. price3 = shieldCount * shieldPrice;
  26. if(shieldCount % 2 === 0){
  27. armorCount++;
  28. price4 = armorPrice * armorCount;
  29. }
  30. }
  31.  
  32. }
  33. price = price1 + price2 + price3 + price4;
  34. console.log(`Gladiator expenses: ${price.toFixed(2)} aureus`);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment