Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. function tradeCommission (input) {
  2. let city = input.shift();
  3. let sells = +input.shift();
  4. let commission = 0;
  5.  
  6. switch (city){
  7. case "Sofia" :
  8. if (sells >= 0 && sells <= 500) {
  9. commission = sells * 0.05
  10. } else if (sells > 500 && sells <= 1000) {
  11. commission = sells * 0.07
  12. } else if (sells > 1000 && sells <= 10000) {
  13. commission = sells * 0.08
  14. } else if (sells > 10000) {
  15. commission = sells * 0.12
  16. } break;
  17.  
  18. case "Varna" :
  19. if (sells >= 0 && sells <= 500) {
  20. commission = sells * 0.045
  21. } else if (sells > 500 && sells <= 1000) {
  22. commission = sells * 0.075
  23. } else if (sells > 1000 && sells <= 10000) {
  24. commission = sells * 0.1
  25. } else if (sells > 10000) {
  26. commission = sells * 0.13
  27. } break;
  28.  
  29. case "Plovdiv" :
  30. if (sells >= 0 && sells <= 500) {
  31. commission = sells * 0.055
  32. } else if (sells > 500 && sells <= 1000) {
  33. commission = sells * 0.08
  34. } else if (sells > 1000 && sells <= 10000) {
  35. commission = sells * 0.12
  36. } else if (sells > 10000) {
  37. commission = sells * 0.145
  38. } break;
  39. }
  40.  
  41. console.log (commission.toFixed(2))
  42. }
  43.  
  44. tradeCommission ([`Sofia,`, 1500])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement