Advertisement
Guest User

Untitled

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