Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pastryShop(input) {
- let type = input[0];
- let quantity = Number(input[1]);
- let date = Number(input[2]);
- let price = 0;
- if (date <= 15) {
- if (type === "Cake") {
- price = 24.0;
- } else if (type === "Souffle") {
- price = 6.66;
- } else if (type === "Baklava") {
- price = 12.60;
- }
- } else if (date > 15) {
- if (type === "Cake") {
- price = 28.7;
- } else if (type === "Souffle") {
- price = 9.8;
- } else if (type === "Baklava") {
- price = 16.98;
- }
- }
- let sum = quantity * price;
- if (date <= 22 && sum >= 100 && sum <= 200) {
- sum -= sum * 0.15;
- } else if (date <= 22 && sum > 200) {
- sum -= sum * 0.25;
- }
- if (date <= 15) {
- sum -= sum * 0.1;
- }
- console.log(sum.toFixed(2))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement