Advertisement
knoteva

Untitled

Aug 14th, 2019
1,137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(lostFightsCount, helmetPrice, swordPrice, shieldtPrice, armorPrice){
  2.  
  3.     let shieldCount = 0;
  4.     let neededMoney = 0;
  5.  
  6.     for(let i = 1; i <= lostFightsCount; i++ ) {
  7.         if(i % 2 === 0){
  8.             neededMoney += +helmetPrice;
  9.         }
  10.         if(i % 3 === 0){
  11.             neededMoney += +swordPrice;
  12.         }
  13.         if(i % 2 === 0 && i % 3 === 0){
  14.             neededMoney += +shieldtPrice;
  15.             shieldCount++;
  16.         }
  17.         if(shieldCount % 2 === 0 && shieldCount > 0){
  18.             neededMoney += +armorPrice;
  19.             shieldCount = 0;
  20.         }
  21.     }
  22.     console.log(`Gladiator expenses: ${neededMoney.toFixed(2)} aureus`);
  23. }
  24.  
  25.  //solve([23], [12.50], [21.50], [40], [200]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement