Trade Commissions
unknown
javascript
9 months ago
1.7 kB
27
Indexable
Never
function tradeCommissions(input) { let town = (input[0]); let sales = (input[1]); let commisssion = 0; if (sales > 0 && sales <= 500) { switch (town) { case "Sofia": console.log((commisssion = sales * 0.05).toFixed(2)); break; case "Varna": console.log((commisssion = sales * 0.045).toFixed(2)); break; case "Plovdiv": console.log((commisssion = sales * 0.055).toFixed(2)); break; default: console.log("error"); } } else if (sales <= 1000) { switch (town) { case "Sofia": console.log((commisssion = sales * 0.07).toFixed(2)); break; case "Varna": console.log((commisssion = sales * 0.075).toFixed(2)); break; case "Plovdiv": console.log((commisssion = sales * 0.08).toFixed(2)); break; default: console.log("error"); } } else if (sales <= 10000) { switch (town) { case "Sofia": console.log((commisssion = sales * 0.08).toFixed(2)); break; case "Varna": console.log((commisssion = sales * 0.1).toFixed(2)); break; case "Plovdiv": console.log((commisssion = sales * 0.12).toFixed(2)); break; default: console.log("error"); } } else if (sales > 1000) { switch (town) { case "Sofia": console.log((commisssion = sales * 0.12).toFixed(2)); break; case "Varna": console.log((commisssion = sales * 0.13).toFixed(2)); break; case "Plovdiv": console.log((commisssion = sales * 0.145).toFixed(2)); break; default: console.log("error"); } } else { console.log("error"); } } tradeCommissions(["Plovdiv", "-500"]);
Leave a Comment