Get the name of a number, even if it's stupidly big.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
此仓库已存档。您可以查看文件和克隆,但不能推送或创建工单/合并请求。

30 行
582 B

  1. import getHundredName from './getHundredName'
  2. import NAMES from './names.json'
  3. interface GetThousandName {
  4. (hundreds: number, tens: number, ones: number): string,
  5. }
  6. const getThousandName: GetThousandName = (hundreds, tens, ones) => {
  7. if (hundreds === 0) {
  8. return getHundredName(tens, ones)
  9. }
  10. if (tens === 0 && ones === 0) {
  11. return [
  12. NAMES.base.units[hundreds],
  13. NAMES.hundred,
  14. ]
  15. .join(' ')
  16. }
  17. return [
  18. NAMES.base.units[hundreds],
  19. NAMES.hundred,
  20. getHundredName(tens, ones),
  21. ]
  22. .join(' ')
  23. }
  24. export default getThousandName