Advertisement
AlexTasev

01_GladiatorExpenses -Exam24Apr2018

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