I have been working on a JavaScript function to convert numbers into a comma-separated format with two decimal places:
Here is my current code snippet:
Number(parseFloat(n).toFixed(2)).toLocaleString('en');
The issue with this code is that it does not show two decimal places (.00) for whole numbers.
I am looking for the following results for a set of numbers:
10000 => 100,00.00
123233.12 => 123,233.12
300000.5 => 300,000.50
Any help or suggestions would be greatly appreciated. Thank you.