Advertisement
Spocoman

Series

Mar 15th, 2022
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function series(input) {
  2.     let budget = Number(input.shift());
  3.     let volume = Number(input.shift());
  4.  
  5.     for (let i = 0; i < volume; i++) {
  6.         let name = input.shift();
  7.         let cash = Number(input.shift());
  8.  
  9.         switch (name) {
  10.             case "Thrones":
  11.                 cash /= 2;
  12.                 break;
  13.             case "Lucifer":
  14.                 cash *= 0.6;
  15.                 break;
  16.             case "Protector":
  17.                 cash *= 0.7;
  18.                 break;
  19.             case "TotalDrama":
  20.                 cash *= 0.8;
  21.                 break;
  22.             case "Area":
  23.                 cash *= 0.9;
  24.                 break;
  25.         }
  26.         budget -= cash;
  27.     }
  28.  
  29.     if (budget >= 0) {
  30.         console.log(`You bought all the series and left with ${budget.toFixed(2)} lv.`);
  31.     } else {
  32.         console.log(`You need ${Math.abs(budget).toFixed(2)} lv. more to buy the series!`);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement