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!

  • Good job, the grammar is correct and it works well.
    – mpnm
    Jul 31, 2019 at 19:14
  • I second that, works fine! The result seems to have line breaks after thousands, then after hundreds. Is that intentional? Maybe that comes from "write.innerHTML = result.replace(/,/g, '<br>');" the <br>?
    – Pedroski
    Jul 31, 2019 at 23:06

1 Answer 1


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 四萬一千零九.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.