Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function coffeeMachine(arg1, arg2, arg3) {
- let drink = arg1;
- let sugar = arg2;
- let drinksCount = Number(arg3);
- let totalPrice = 0;
- switch (drink) {
- case "Espresso":
- if (sugar === "Without") {
- totalPrice += drinksCount * 0.9;
- totalPrice -= totalPrice * 0.35;
- } else if (sugar === "Normal") {
- totalPrice += drinksCount * 1;
- } else if (suggar === "Extra") {
- totalPrice += drinksCount * 1.20;
- }
- break;
- }
- if (drink === "Espresso" && drinksCount >= 5) {
- totalPrice -= totalPrice * 0.25;
- }
- if (totalPrice >= 15) {
- totalPrice -= totalPrice * 0.20;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement