In the project, use JavaScript to convert numbers to uppercase amounts, and share them with you.
var digituppercase = function (n) {
var fraction = [' Corner ', ' min '];
var digit = [
' 0 ', ' one ', ' II ', ' three ', ' Restaurant ',
' Wu ', ' Lu ', ' qi ', ' ba ', ' JIU '
];
var unit = [
[' Yuan ', ' million ', ' billion '],
[', ' Pick ', ' bai ', ' thousand ']
];
var head = N < 0? ' Owed ': ';
n = Math.Abs (n);
var s = ';
for (var i = 0; i < fraction.length; i++) {
S + + (Digit[math.floor (n * * MATH.POW (i))%] + fraction[i]). Replace (/0./, ');
}
s = S ' whole ';
n = Math.floor (n);
for (var i = 0; i < unit[0].length && n > 0; i++) {
var p = ';
for (var j = 0; J < unit[1].length && n > 0; j +) {
p = digit[n%] + unit[1][j] + p;
n = Math.floor (N/10);
}
s = p.replace (/(0.) * 0 $/, '). Replace (/^$/, ' 0 ') + unit[0][i] + s;
}
Return head + s.replace (/(0) * 0 yuan/, ' yuan ')
. Replace (/(0.) +/g, ' 0 ')
. replace (/^ whole $/, ' 0 yuan whole ');
};
Console.log (Digituppercase (7682.01)); Qi Qian Lu Bai ba pick up a point
Console.log (Digituppercase (7682)); Qi Qian Lu Bai ba to pick up the whole
Console.log (Digituppercase (951434677682.00)); Nine thousand Wu Bai Yi to pick up the restaurant hundred thousand thousands of QI million Lu Bai Ba to pick up the whole