var finalTotal = 0;
var calculateTax = function(subtotal,taxRate) {
var calculateTax = subtotal * taxRate;
var salesTax = parseFloat(calculateTax.toFixed(2));
return salesTax;
};
finalTotal = calculateTax(1500,.0625);
alert(finalTotal);
var finalTotal = 0;
var calculateTax = function(subtotal,taxRate) {
var calculateTax = subtotal * taxRate;
var salesTax = parseFloat(calculateTax.toFixed(2));
return salesTax;
};
finalTotal = calculateTax(1500,.0625);
alert(finalTotal);
I see any logical error here, your function is returning the value of the taxe calculated on the base of 6.25% (93.75 in your case).
According to your variables naming i guess that you wanted the final total which is (salesTax + subtotal), if is this what you want you only need to make this change :
return salesTax + subtotal;