const toChineseNum = (num) => {
const unit = ['', '十', '百', '千']
const counts = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'] const pre = Math.floor(num / 10000)
const next = num % 10000 let getfour = (mynum, flag = false) => {
if(!mynum){return ''}
let i = 0, str = '' while(flag ? i < 4 : mynum > 0 ) {
count = mynum % 10
mynum = Math.floor(mynum / 10)
str = (count ? counts[count] + unit[i] : str[0] == '零' ? '' : str.length && i ? '零' : '') + str
i++
}
return str
} return pre ? getfour(pre) + '万' + getfour(next, true) : getfour(num)
}
console.log(toChineseNum(59900670))