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 quantity = Number(input[2]);
- let price = 0;
- switch(size) {
- case "small":
- if (fruit === "Watermelon") {
- price = 56 * 2;
- } else if (fruit === "Mango") {
- price = 36.66 * 2;
- } else if (fruit === "Pineapple") {
- price = 42.10 * 2;
- } else if (fruit === "Raspberry") {
- price = 20 * 2;
- }
- break;
- case "big":
- if (fruit === "Watermelon") {
- price = 28.70 * 5;
- } else if (fruit === "Mango") {
- price = 19.60 * 5;
- } else if (fruit === "Pineapple") {
- price = 24.80 * 5;
- } else if (fruit === "Raspberry") {
- price = 15.20 * 5;
- }
- break;
- }
- let totalPrice = price * quantity;
- if (totalPrice >= 400 && totalPrice <= 1000) {
- totalPrice -= totalPrice * 0.15;
- }
- if (totalPrice > 1000) {
- totalPrice -= totalPrice * 0.50;
- }
- console.log(`${totalPrice.toFixed(2)} lv.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment