Let's say I have a line: 33400298.57
I wrote a function (too long, too bloated, too custom to post here) that formats this:
33,400,298.57
Soft logic is the insertion of commas - to the left of the decimal point, every three places. Could there be a single line solution using regex for this? I am currently splitting, reversing, looping to insert, reverse and join again. Needless to say, this is not optimal.
I am looking for something like this:
Random color generator: '#' + Math.floor (Math.random () * 16777215) .toString (16);
Thank.
source
share