I have the following code:
function numberParaReal(numero){
var formatado = "R$ " + numero.toFixed(2).replace(".",",");
return formatado;
}
function realParaNumber(texto){
var compativelComParseFloat = texto.replace("R$ ","");
compativelComParseFloat = compativelComParseFloat.replace(",",".");
var valor = parseFloat(compativelComParseFloat);
return valor;
}
But it only displays values in this format: 1000.00.
I wanted to leave it like this: 1,000.00 ~ 100,000.00 ~ 10,000,000.00 and so on ...
It would be something like 3 houses before the comma gets point, just do not know how to do that.
Probably there should be functions ready for this type of situation, however as I am learning, it would not be ideal to use ready-made functions.