149
rated 0 times
[
156]
[
7]
/ answers: 1 / hits: 63715
/ 6 Years ago, mon, april 9, 2018, 12:00:00
My formatter looks like this
const formatter = new Intl.NumberFormat('en-NZ', {
style: 'currency',
currency: 'NZD',
minimumFractionDigits: 2,
});
How can I adjust this so that whole numbers have 0 fraction digits
formatter.format(4); // want output $4
whilst fractions always show two digits?
formatter.format(4.1); // want output $4.10
More From » javascript