I'm working on a tax calculator app with JavaScript and have a problem adding let values.
When trying to add 3 different tax values together, in the console, the answer I always get is the first of the values.
let basicRate,
higherRate,
additionalRate;
function calculateTaxDue(grossSalary) {
if (grossSalary > 150000) {
basicRate = parseFloat((46351 - 11000) * 0.2).toFixed(2);
higherRate = parseFloat((150000 - 46351) * 0.4).toFixed(2);
additionalRate = parseFloat((grossSalary - 150000) *
0.45).toFixed(2)
taxDue = parseFloat((basicRate + higherRate +
additionalRate)).toFixed(2);
}
}
calculateTaxDue(150001)
console.log(parseFloat(basicRate).toFixed(2));
console.log(parseFloat(higherRate).toFixed(2));
console.log(parseFloat(additionalRate).toFixed(2));
console.log(parseFloat(basicRate + higherRate +
additionalRate).toFixed(2));
Just prints the first value (basicRate) to the console. I'm confused by this.
Apologies for lack of detail first time around.
Thanks