var calcTotalprice = function () {
var price1 = parseFloat($('#price1').html());
var price2 = parseFloat($('#price2').html());
overall = (price1+price2);
$('#total-amount').html(overall);
}
var price1 = 1.99;
var price2 = 5.47;
How to add function to change dot to comma in price number and round it to two decimal
You can use “.toFixed(x)” function to round your prices:
And then you can use method “.toString()” to convert your value to string:
Also, you can use method “.replace(“..”,”..”)” to replace “.” for “,”:
Result:
Updated answer
.toFixed already returns a string, so doing .toString() is not needed.
This is more than enough: