The idea is not to have to convert the result to two decimal places at all times. Example:
var preco = 10.00
To show these decimal places, I have to put it like this:
$("#preco").html("R$ " + preco.toFixed(2));
And then if I do any calculations:
preco += 10
$("#preco").html("R$ " + preco.toFixed(2));
Again I have to put toFixed(2)
.
So the question is: Is there any way to always leave this variable with two decimal places, without having to use toFixed()
multiple times?