Page is a not externally linkable
ggrot - 6:24 pm on Oct 11, 2001 (gmt 0)
given string n which is your number and assumming: loop through the characters in n to find the first occurence of the '.' character. Record it's index in n. If you dont find it, set the index to be the length of n starting from the front of n, use the mod 3 of the index of the '.' minus index of the current character to determine if a comma should be inserted behind it. loop through n until you reach the '.' character.
I don't remember javascript syntax well, but how 'bout an algorithm: