Hello, I am making a commission calculator for a client. I have basic functionality down but the ability to combine multiple options does not work. What am I doing wrong?
let selectedPrice = 0;
function updateCalc(){
if (ecCheck.checked){
ecValue.disabled = false;
} else if (!ecCheck.checked){
ecValue.disabled = true;
}
const type = priceMenu.value;
switch (type) {
case "line":
selectedPrice = 40;
break;
case "mono":
selectedPrice = 80;
break;
case "daki":
selectedPrice = 350;
break;
case "flat":
selectedPrice = 100;
break;
}
const extraRevCost = ( 10 / 100) * Number(selectedPrice);
const rushPercentageResult = ( 40 / 100) * Number(selectedPrice);
const ecPercentageResult = ( 10 / 100) * Number(selectedPrice) * ecValue.value;;
if (rushCheck.checked){
currentPrice(rushPercentageResult);
console.log(total)
} else if (ecCheck.checked) {
currentPrice(ecPercentageResult);
console.log(total)
} else if (extraRev.checked){
currentPrice(extraRevCost);
console.log(total)
} else if (commercialRights.checked) {
currentPrice(75)
console.log(total)
}
else {
total = selectedPrice;
}
return calcResult.textContent = total;
}
function currentPrice(calculatedFees){
return total = calculatedFees + selectedPrice;
}```