Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function energyBooster(input) {
- let fruit = input[0];
- let size = input[1];
- let volume = Number(input[2]);
- let sumFruit = 0;
- switch (fruit) {
- case "Watermelon":
- if (size === "small") {
- sumFruit = 56 * 2;
- } else if (size === "big") {
- sumFruit = 28.7 * 5;
- }
- break;
- case "Mango":
- if (size === "small") {
- sumFruit = 36.66 * 2;
- } else if (size === "big") {
- sumFruit = 19.6 * 5;
- }
- break;
- case "Pineapple":
- if (size === "small") {
- sumFruit = 42.1 * 2;
- } else if (size === "big") {
- sumFruit = 24.8 * 5;
- }
- break;
- case "Raspberry":
- if (size === "small") {
- sumFruit = 20 * 2;
- } else if (size === "big") {
- sumFruit = 15.2 * 5;
- }
- break;
- }
- let total = sumFruit * volume;
- if (total >= 400 && total <= 1000) {
- total *= 0.85;
- } else if (total > 1000) {
- total /= 2;
- }
- console.log(`${total.toFixed(2)} lv.`);
- }
- Фундаменталс решение:
- function energyBooster([fruit, size, volume]) {
- let total = {
- "Watermelon": {"small": 112, "big": 143.5},
- "Pineapple": {"small": 84.2, "big": 124},
- "Raspberry": {"small": 40, "big": 76},
- "Mango": {"small": 73.32, "big": 98}
- }[fruit][size] * volume;
- total = total >= 400 && total <= 1000? total * 0.85 : total > 1000 ? total / 2 : total;
- console.log(`${total.toFixed(2)} lv.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement