Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tradeCommission (input) {
- let city = input.shift();
- let sells = +input.shift();
- let commission = 0;
- switch (city){
- case "Sofia" :
- if (sells >= 0 && sells <= 500) {
- commission = sells * 0.05
- } else if (sells > 500 && sells <= 1000) {
- commission = sells * 0.07
- } else if (sells > 1000 && sells <= 10000) {
- commission = sells * 0.08
- } else if (sells > 10000) {
- commission = sells * 0.12
- } break;
- case "Varna" :
- if (sells >= 0 && sells <= 500) {
- commission = sells * 0.045
- } else if (sells > 500 && sells <= 1000) {
- commission = sells * 0.075
- } else if (sells > 1000 && sells <= 10000) {
- commission = sells * 0.1
- } else if (sells > 10000) {
- commission = sells * 0.13
- } break;
- case "Plovdiv" :
- if (sells >= 0 && sells <= 500) {
- commission = sells * 0.055
- } else if (sells > 500 && sells <= 1000) {
- commission = sells * 0.08
- } else if (sells > 1000 && sells <= 10000) {
- commission = sells * 0.12
- } else if (sells > 10000) {
- commission = sells * 0.145
- } break;
- }
- console.log (commission.toFixed(2))
- }
- tradeCommission ([`Sofia,`, 1500])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement