I want to format a number so that it always have at least two decimal places.
Samples:
1
2.1
123.456
234.45
Output:
1.00
2.10
123.456
234.45
I want to format a number so that it always have at least two decimal places.
Samples:
1
2.1
123.456
234.45
Output:
1.00
2.10
123.456
234.45
How about using Intl :
Intl.NumberFormat(navigator.language, {
minimumFractionDigits: 2,
maximumFractionDigits: 10,
}).format(num)