Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pastryShop(input) {
- let pastryType = input[0];
- let quantity = Number(input[1]);
- let day = Number(input[2]);
- let pricePerPastry = 0;
- switch(pastryType) {
- case "Cake":
- if (day <= 15) {
- pricePerPastry = 24;
- } else {
- pricePerPastry = 28.70;
- }
- break;
- case "Souffle":
- if (day <= 15) {
- pricePerPastry = 6.66;
- } else {
- pricePerPastry = 9.80;
- }
- break;
- case "Baklava":
- if (day <= 15) {
- pricePerPastry = 12.60;
- } else {
- pricePerPastry = 16.98;
- }
- break;
- }
- let price = quantity * pricePerPastry;
- if (day <= 22) {
- if (price >= 100 && price <= 200) {
- price = price - (price * 0.15);
- } else if (price > 200) {
- price = price - (price * 0.25);
- }
- }
- if (day <= 15) {
- price = price - (price * 0.1);
- }
- console.log(price.toFixed(2));
- }
Add Comment
Please, Sign In to add comment