Writing-out numbers in mandarin till 19999 algorithm My current task includes writing-out numbers in different languages, also mandarin. I have never grappled with mandarin but I checked several resource and tested my algorithm to the best of my believe. But to really make sure that everything works fine I would highly appreciate a second look of a native speaker. Since I don't know any native speakers I came to this place looking for help.

My algorithm can be accessed here: https://codepen.io/f16r/pen/xvrwOx
It is intended to work from 0 to 19999.

Any help is highly appreciated.
Thank you very much!
Your algorithm have to handle 0 between first and last digits as well. Insert 零 for those cases.
For example,

10003 should be 一萬零三.
10301 should be 一萬零三百零一.
30028 should be 三萬零二十八.
41009 should be 四萬一千零九.