I'm using JS' Intl.Numberformat function, but is there a way I can replace the output that's now:
ANG12.45
Format to: fl. 12.45
So replace the default currencyDisplay
to a custom naming including a space between the symbol and value?
value = parseFloat(value);
var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'ANG',
currencyDisplay: 'symbol',
minimumFractionDigits: 2
});
return formatter.format(value);
I'm using JS' Intl.Numberformat function, but is there a way I can replace the output that's now:
ANG12.45
Format to: fl. 12.45
So replace the default currencyDisplay
to a custom naming including a space between the symbol and value?
value = parseFloat(value);
var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'ANG',
currencyDisplay: 'symbol',
minimumFractionDigits: 2
});
return formatter.format(value);
Share
Improve this question
edited Aug 6, 2023 at 14:22
Penny Liu
17.6k5 gold badges86 silver badges108 bronze badges
asked May 14, 2018 at 9:42
user1469734user1469734
82114 gold badges52 silver badges94 bronze badges
3
- Did you solve the problem? – camelsWriteInCamelCase Commented May 22, 2018 at 22:08
-
1
Yes:
return formatter.format(value).replace("ANG", "ƒ ");
– user1469734 Commented May 23, 2018 at 11:05 - Then you need to accept your own answer. – camelsWriteInCamelCase Commented May 23, 2018 at 12:11
2 Answers
Reset to default 8return formatter.format(value).replace("ANG", "ƒ ");
This can not be done with the Intl.NumberFormat
object, because the value of the "currency" parameter must be in ISO 4217 currency codes list and there is no "FL" there.