Advertisement
Guest User

Untitled

a guest
Apr 10th, 2020
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. function fruitShop(fruit, day, quantity) {
  2.  
  3. quantity = Number(quantity);
  4.  
  5. let price = 0;
  6.  
  7. if (day == "saturday" || day == "sunday") {
  8.  
  9. if (fruit == "banana") price = 2.70;
  10. else if (fruit == "apple") price = 1.25;
  11. else if (fruit == "orange") price = 0.90;
  12. else if (fruit == "grapefruit") price = 1.60;
  13. else if (fruit == "kiwi") price = 3.00;
  14. else if (fruit == "pineapple") price = 5.60;
  15. else if (fruit == "grapes") price = 4.20;
  16.  
  17. } else if (day == "monday" || day == "tuesday" || day == "wednesday" || day == "thursday" || day == "friday") {
  18.  
  19. if (fruit == "banana") price = 2.50;
  20. if (fruit == "apple") price = 1.20;
  21. if (fruit == "orange") price = 0.85;
  22. if (fruit == "grapefruit") price = 1.45;
  23. if (fruit == "kiwi") price = 2.70;
  24. if (fruit == "pineapple") price = 5.50;
  25. if (fruit == "grapes") price = 3.85;
  26.  
  27. } if (price > 0) {
  28. console.log(price * quantity.toFixed(2))
  29. } else {
  30. console.log("error")
  31. }
  32.  
  33.  
  34.  
  35.  
  36.  
  37. }
  38. fruitShop("apple", "tuesday", "2")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement