Here's what I need:
121 => 121
14231.439400000 => 14,231.4394
1.123456789 => 1.12345679
-9012.4430001 => -9,012.4430001
I've tried the following: return input.toFixed(8).toLocaleString().replace(/0*$/, '').replace(/\.$/, '');
and that doesn't add commas. I've also looked at numeraljs
, but that doesn't have the decimal features I require (specifying up to 8 decimals out, or trimming)
Any help?