SHARE
TWEET

Untitled

knoteva Aug 14th, 2019 64 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]);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top