js digital-to-yuan capital

numToCny (n-) {
the let fraction = [ 'angles',' partial ']
the let digit for = [
' zero ',' One ',' II ',' three ',' store ',
' Wu ',' LU ',' qi ',' split ',' ND '
];
the let Unit = [
[' element, 'the' ',' one hundred million ']
[', 'pick up', 'Bai', 'thousand']
];
the let head = n <0 'under':? ''
n-the Math.abs = (n-)
the let S = ''
for (the let I = 0; I <fraction.length; I ++) {
S + = (digit for [Math.floor ( math.floor (n * 1000 * 10 * Math.pow (10, i))% (10 * 1000) / 1000)] + fraction [i]). replace (/ zero ./, '')
}
S = S || 'integer'
n-Math.floor = (n-)
for (the let I = 0; I <Unit [0].length && n > 0; i++) {
let p = ''
for (let j = 0; j < unit[1].length && n > 0; j++) {
p = digit[n % 10] + unit[1][j] + p
Math.floor = n-(n-/ 10)
}
S = p.replace (/ (zero.) Zero * $ /, '') .replace ( / ^ $ /, ' zero') + unit [0] [ i] S +
}
return head s.replace does + (/ (zero.) * zero element / 'meta')
.replace (/ (zero.) + / g, 'zero')
.replace (/ ^ entire $ / ' zero element whole ')
}

 

Guess you like

Origin www.cnblogs.com/chenlw/p/11646294.html