I have a number 1000 in an object.
I want it to be in 1,000.00
format
I tried:
obj[key] = (parseFloat(obj[key]).toFixed(2)).toLocaleString();
This gives 1000.00
I have a number 1000 in an object.
I want it to be in 1,000.00
format
I tried:
obj[key] = (parseFloat(obj[key]).toFixed(2)).toLocaleString();
This gives 1000.00
Edited answer to account for numbers with no remainder:
Use the options in toLocaleString();
Try this:
obj[key] = obj[key].toLocaleString(undefined,{minimumFractionDigits: 2, maximumFractionDigits: 2});
No need to parse as float in this case. Hope this helps.