Advertisement
ivo_petkov01

Untitled

Mar 13th, 2022
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function smallShop(input) {
  2.  
  3.     let product = input[0];
  4.     let city = input[1];
  5.     let quantity = Number(input[2]);
  6.     let price = 0;
  7.  
  8.     if (city === "Sofia") {
  9.         if (product === "coffee") {
  10.             price = 0.50;
  11.         } else if (product === "water") {
  12.             price = 0.80;
  13.         } else if (product === "beer") {
  14.             price = 1.20;
  15.         } else if (product === "sweets") {
  16.             price = 1.45;
  17.         } else if (product === "peanuts") {
  18.             price = 1.60;
  19.         }
  20.     } else if (city === "Plovdiv") {
  21.         if (product === "coffee") {
  22.             price = 0.40;
  23.         } else if (product === "water") {
  24.             price = 0.70;
  25.         } else if (product === "beer") {
  26.             price = 1.15;
  27.         } else if (product === "sweets") {
  28.             price = 1.30;
  29.         } else if (product === "peanuts") {
  30.             price = 1.50;
  31.         }
  32.     } else if (city === "Varna") {
  33.         if (product === "coffee") {
  34.             price = 0.45;
  35.         } else if (product === "water") {
  36.             price = 0.70;
  37.         } else if (product === "beer") {
  38.             price = 1.10;
  39.         } else if (product === "sweets") {
  40.             price = 1.35;
  41.         } else if (product === "peanuts") {
  42.             price = 1.55;
  43.         }
  44.     }
  45.     console.log(price * quantity);
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement