Advertisement
Guest User

Untitled

a guest
May 18th, 2021
1,393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function tradeComm(input) {
  2.  
  3.     let city = input[0];
  4.     let sales = Number(input[1]);
  5.     if (0 <= sales && sales <= 500) {
  6.         switch (city) {
  7.             case 'Sofia': console.log((sales * 0.05).toFixed(2)); break;
  8.             case 'Varna': console.log((sales * 0.045).toFixed(2)); break;
  9.             case 'Plovdiv': console.log((sales * 0.055).toFixed(2)); break;
  10.             default: console.log('error'); break;
  11.         }
  12.     } else if (500 < sales && sales <= 1000) {
  13.         switch (city) {
  14.             case 'Sofia': console.log((sales * 0.07).toFixed(2)); break;
  15.             case 'Varna': console.log((sales * 0.075).toFixed(2)); break;
  16.             case 'Plovdiv': console.log((sales * 0.08).toFixed(2)); break;
  17.             default: console.log('error'); break;
  18.         }
  19.     } else if (1000 < sales && sales <= 10000) {
  20.             switch (city) {
  21.             case 'Sofia': console.log((sales * 0.08).toFixed(2)); break;
  22.             case 'Varna': console.log((sales * 0.10).toFixed(2)); break;
  23.             case 'Plovdiv': console.log((sales * 0.12).toFixed(2)); break;
  24.             default: console.log('error'); break;
  25.         }
  26.     } else if (sales > 10000) {
  27.         switch(city) {
  28.             case 'Sofia': console.log((sales * 0.12).toFixed(2)); break;
  29.             case 'Varna': console.log((sales * 0.13).toFixed(2)); break;
  30.             case 'Plovdiv': console.log((sales * 0.145).toFixed(2)); break;
  31.             default: console.log('error'); break;
  32.         }
  33.     }
  34.       else{
  35.       console.log('error');
  36.       }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement