Advertisement
NikolayNenchev

smallShop

Jan 26th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. function smallShop(input){
  2. let productName = input.shift();
  3. let town = input.shift();
  4. let quantity = Number(input.shift());
  5. let totalSum =0.0;
  6. if (productName=="coffee"){
  7. if(town == "Sofia"){
  8. totalSum = quantity*0.5;
  9. }else if(town == "Plovdiv"){
  10. totalSum = quantity*0.4;
  11. }else if(town =="Varna"){
  12. totalSum = quantity*0.45;
  13. }
  14. }
  15. if (productName=="water"){
  16. if(town == "Sofia"){
  17. totalSum = quantity*0.8;
  18. }else if(town == "Plovdiv"){
  19. totalSum = quantity*0.7;
  20. }else if(town =="Varna"){
  21. totalSum = quantity*0.7;
  22. }
  23. }
  24. if (productName=="beer"){
  25. if(town == "Sofia"){
  26. totalSum = quantity*1.2;
  27. }else if(town == "Plovdiv"){
  28. totalSum = quantity*1.15;
  29. }else if(town =="Varna"){
  30. totalSum = quantity*1.1;
  31. }
  32. }
  33. if (productName=="sweets"){
  34. if(town == "Sofia"){
  35. totalSum = quantity*1.45;
  36. }else if(town == "Plovdiv"){
  37. totalSum = quantity*1.30;
  38. }else if(town =="Varna"){
  39. totalSum = quantity*1.35;
  40. }
  41. }
  42. if (productName=="peanuts"){
  43. if(town == "Sofia"){
  44. totalSum = quantity*1.60;
  45. }else if(town == "Plovdiv"){
  46. totalSum = quantity*1.50;
  47. }else if(town =="Varna"){
  48. totalSum = quantity*1.55;
  49. }
  50. }
  51. console.log(totalSum);
  52.  
  53.  
  54.  
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement