Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function chocho(input) {
- let fruits = input[0];
- let dayOfWeek = input[1];
- let quantity = Number(input[2]);
- let priceTotal = 0;
- if (dayOfWeek === "Monday" || "Tuesday" || "Wednesday" || "Wednesday" || "Thursday" || "Friday") {
- if(fruits === "banana") {
- priceTotal = 2.50 * quantity;
- } else if (fruits === "apple") {
- priceTotal = 1.20 * quantity;
- }else if(fruits === "orange") {
- priceTotal = 0.85 * quantity;
- }else if(fruits === "grapefruit") {
- priceTotal = 1.45 * quantity;
- }else if(fruits === "kiwi") {
- priceTotal = 2.70 * quantity;
- }else if(fruits === "pineapple") {
- priceTotal = 5.50 * quantity;
- }else if(fruits === "grapes") {
- priceTotal = 3.85 * quantity;
- } else {
- priceTotal = "error";
- }
- }
- else if (dayOfWeek === "Saturday" || "Sunday") {
- if(fruits === "banana") {
- priceTotal = 2.70 * quantity;
- } else if(fruits === "apple") {
- priceTotal = 1.25 * quantity;
- }else if(fruits === "orange") {
- priceTotal = 0.90 * quantity;
- }else if(fruits === "grapefruit") {
- priceTotal = 1.60 * quantity;
- }else if(fruits === "kiwi") {
- priceTotal = 3.00 * quantity;
- }else if(fruits === "pineapple") {
- priceTotal = 5.60 * quantity;
- }else if(fruits === "grapes") {
- priceTotal = 4.20 * quantity;
- } else {
- priceTotal = "error";
- }
- }
- else {
- priceTotal = "error";
- }
- if (priceTotal === "error") {
- console.log(`${priceTotal}`);
- } else {
- console.log(`${priceTotal.toFixed(2)}`);
- }
- }
- chocho(["apple","Monday","2"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement