I have a script that takes a big number and counts up. The script converts the number to a string so that it can be formatted with commas, but I also need to add a decimal place before the last two digits. I know that this line handles the commas:
if ((i+1) % 3 == 0 && (amount.length-1) !== i)output = ',' + output;
Is there a similar line of code I can add that accomplishes adding a decimal point?
Yes, if you always want the decimal before the last two:
When
commaFunc()is the function you described that adds commas.EDIT
After much hard work, the full correct code:
http://jsfiddle.net/nayish/TT8BH/21/