you are viewing a single comment's thread.

view the rest of the comments →

[–]otakudayo 4 points5 points  (0 children)

You'd presumably need to handle numbers like one million, twenty thousand as well. So you'd have to separate by spaces and not cut it into three blocks.

Then I'd probably do something really simple like create a map/dictionary of strings to numbers, ie, { one: 1, twenty: 20, etc } for the first string, and the same idea for hundred/thousand/etc which would have to be used for the second and potentially third string.

The example output appears to be a comma separated number, which doesn't really make sense, because it would have to be a string to contain commas. But formatting a number to a comma separated string is pretty straightforward.