i want to add if topic includes "fi" then com = premium * 0.23 in to this code ..
let com;
if (premium < 1900) {
com = premium * 0.12;
} else {
com = premium * 0.18;
}
Certainly! If you want to add an additional condition for when the topic
includes “fi,” you can modify the com
calculation accordingly. Here’s the updated code:
function calculatePremium() {
// ... (your existing code) ...
// Calculate commission (com)
if (topic.includes("fi")) {
com = premium * 0.23; // If topic includes "fi," set commission to 23%
} else if (premium < 1900) {
com = premium * 0.12;
} else {
com = premium * 0.18;
}
// ... (rest of your existing code) ...
}
This modification checks whether the topic
includes “fi.” If it does, the commission (com
) is set to premium * 0.23
. If not, it proceeds with the existing conditions for calculating the commission based on the premium amount.
Make sure to replace the existing commission calculation in your code with this updated block.