//Value being parsed at this point is "150.00"
var productValue = parseFloat($("#product-cost-value-value").text().replace(',', '.'));
console.log(productValue);
The value being logged is 150
.
However if I add some value to it, like this. The value changes to display the two decimals I want.
console.log(productValue + 0.01);
The value being logged is 150.01
How can I force my values to show two decimal places at all time?
use:
console.log(productValue.toFixed(2));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With