Advertisement
Guest User

Untitled

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