Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function three(input) {
- let fruit = input.shift();
- let smallOrBig = input.shift();
- let number = Number(input.shift());
- let sumSmall = 0;
- let sumBig = 0;
- let finalPrice = 0;
- // Watermelon", "Mango", "Pineapple" или "Raspberry
- if (fruit === "Watermelon") {
- switch (smallOrBig) {
- case "small":
- sumSmall = 2 * 56;
- finalPrice = sumSmall * number;
- break;
- case "big":
- sumBig = 5 * 28.70;
- finalPrice = sumBig * number;
- break;
- }
- } else if (fruit === "Mango") {
- switch (smallOrBig) {
- case "small":
- sumSmall = 2 * 33.66;
- finalPrice = sumSmall * number;
- break;
- case "big":
- sumBig = 5 * 19.60;
- finalPrice = sumBig * number;
- break;
- }
- } else if (fruit === "Pineapple") {
- switch (smallOrBig) {
- case "small":
- sumSmall = 2 * 42.10;
- finalPrice = sumSmall * number;
- break;
- case "big":
- sumBig = 5 * 24.80;
- finalPrice = sumBig * number;
- break;
- }
- } else if (fruit === "Raspberry") {
- switch (smallOrBig) {
- case "small":
- sumSmall = 2 * 20;
- finalPrice = sumSmall * number;
- break;
- case "big":
- sumBig = 5 * 15.20;
- finalPrice = sumBig * number;
- break;
- }
- }
- if (finalPrice >= 400 && finalPrice <= 1000) {
- finalPrice = finalPrice * 0.85;
- }
- if (finalPrice > 1000) {
- finalPrice = finalPrice * 0.50;
- }
- console.log(`${finalPrice.toFixed(2)} lv.`)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement