Hello i have a question about:
Number.prototype.toLocaleString()
Trouble is that when we use "toLocaleString()" method it will not show latest maximumFractionDigits value if there was "0".
var i = 50456.40345345;
i.toLocaleString('en-US', {maximumFractionDigits: 2})
// It will return "50,456.4".
// I want to see "50,456.40".
How can i do that?
Use minimumFractionDigits:
var i = 50456.40345345;
i = i.toLocaleString('en-US', {maximumFractionDigits: 2, minimumFractionDigits: 2});
document.write(i);
Although you are specifying the maximumFractionDigits, the numbers don't necessarily have 2 fraction digits, so that's why you need to specify minimumFractionDigits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With