Home >Web Front-end >JS Tutorial >JavaScript method to convert numbers into uppercase integer amounts_javascript skills
The example in this article describes the method of converting numbers into uppercase integer amounts using JavaScript. Share it with everyone for your reference. The specific implementation method is as follows:
var s = '';
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 % 10] unit[1][j] p;
n = Math.floor(n / 10);
}
s = p.replace(/(zero.)*zero$/, '')
.replace(/^$/, 'zero')
unit[0][i] s;
}
return s.replace(/(zero.)*zero yuan/, 'yuan')
.replace(/(zero.) /g, 'zero')
.replace(/^$/, 'zero yuan') 'whole';
}
The test code is as follows:
I hope this article will be helpful to everyone’s JavaScript programming design.