const inputNum = 100456789;
const num = Array.from(inputNum+'');
const strArr = '零壹贰叁肆伍陆柒捌玖'
const unit = Array.from('仟佰拾亿仟佰拾万仟佰拾 ')
let result = '元整'
while (num.length) {
const n = num.pop()
result = strArr[n] + unit.pop() + result
}
result = result
.replace('零亿', '亿')
.replace('零万', '万')
.replace('零仟', '零')
.replace('零佰', '零')
.replace('零拾', '零')
while (result.includes('零零')) {
result = result.replace('零零', '零')
}
result = result
.replace('零亿', '亿')
.replace('零万', '万')
.replace('亿万', '亿零')
.replace(' ', '')
console.log(result)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)