Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function series(input) {
- let budget = Number(input.shift());
- let volume = Number(input.shift());
- for (let i = 0; i < volume; i++) {
- let name = input.shift();
- let cash = Number(input.shift());
- switch (name) {
- case "Thrones":
- cash /= 2;
- break;
- case "Lucifer":
- cash *= 0.6;
- break;
- case "Protector":
- cash *= 0.7;
- break;
- case "TotalDrama":
- cash *= 0.8;
- break;
- case "Area":
- cash *= 0.9;
- break;
- }
- budget -= cash;
- }
- if (budget >= 0) {
- console.log(`You bought all the series and left with ${budget.toFixed(2)} lv.`);
- } else {
- console.log(`You need ${Math.abs(budget).toFixed(2)} lv. more to buy the series!`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement