1
I intend in Javascript to have the following result:
Entree | Expected exit |
---|---|
1.6 | 1,60€ |
1 | 1€ |
1.55 | 1,55€ |
I’ve tried to:
num.toLocaleString('pt-PT', {
minimumFractionDigits: 0,
maximumFractionDigits: 2
}) + '€';
But unsuccessfully, since, for input 1.6
, receiving 1,6€
, where I wish for two decimal digits in this type of scenario.
If you are not going to change the format (at least this is what appears in the table), wouldn’t it be simpler just to concatenate the "€"? if you have "1.55" and want to return the same format I don’t understand why use the
toLocaleString
– Ricardo Pontual
@Ricardopontual, the
toLocaleString
is probably to format the number correctly according to the standardpt-PT
. See that12345.67
is different from12 345,67
(formatting result).– Luiz Felipe
yes, but for what it has examples is not necessary, hence my doubt :)
– Ricardo Pontual
@Ricardopunctual, it was my mistake in the edition, I just saw it now, thank you! : ) In fact the original examples showed that yes.
– Luiz Felipe
I need to format, for the pt_EN currency, if the decimal separator is a point it has to be a comma
– Laranja Mecânica