Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. function fruitsShop(input){
  2. let fruit = input.shift();
  3. let day = input.shift();
  4. let quantity = Number(input.shift());
  5. let pirce = 0;
  6.  
  7. if(day === "Monday" || day === "Tuesday" || day === "Wednesday" ||
  8. day === "Thursday" || day === "Friday"){
  9. if(fruit === "banana"){
  10. price = (quantity * 2.50).toFixed(2);
  11. console.log(price);
  12. } else if(fruit === "apple"){
  13. price = (quantity * 1.20).toFixed(2);
  14. console.log(price);
  15. } else if(fruit === "orange"){
  16. price = (quantity * 0.85).toFixed(2);
  17. console.log(price);
  18. } else if(fruit === "grapefruit"){
  19. price = (quantity * 1.45).toFixed(2);
  20. } else if(fruit === "kiwi"){
  21. price = (quantity * 2.70).toFixed(2);
  22. console.log(price);
  23. } else if(fruit === "pineapple"){
  24. price = (quantity * 5.50).toFixed(2);
  25. console.log(price);
  26. } else if (fruit === "grapes"){
  27. price = (quantity * 3.85).toFixed(2);
  28. console.log(price);
  29. } else {
  30. console.log("error")
  31. }
  32.  
  33. } else if(day === "Saturday" || day === "Sunday"){
  34. if(fruit === "banana"){
  35. price = (quantity * 2.70).toFixed(2);
  36. console.log(price);
  37. } else if(fruit === "apple"){
  38. price = (quantity * 1.25).toFixed(2);
  39. console.log(price);
  40. } else if(fruit === "orange"){
  41. price = (quantity * 0.90).toFixed(2);
  42. console.log(price);
  43. } else if(fruit === "grapefruit"){
  44. price = (quantity * 1.60).toFixed(2);
  45. console.log(price);
  46. } else if(fruit === "kiwi"){
  47. price = (quantity * 3.00).toFixed(2);
  48. console.log(price);
  49. } else if(fruit === "pineapple"){
  50. price = (quantity * 5.60).toFixed(2);
  51. console.log(price);
  52. } else if (fruit === "grapes"){
  53. price = (quantity * 4.20).toFixed(2);
  54. console.log(price);
  55. } else {
  56. console.log("error")
  57. }
  58.  
  59. } else{
  60. console.log("error")
  61. }
  62. }
  63.  
  64. fruitsShop(["tomato", "Monday", 0.5])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement