Advertisement
AreWe

small shop bilqna

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