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