Sometimes we might need to convert a thousand dollars into a thousand dollars something like that

Take no thank

Sometimes we may need to1000= > abovevar digitUppercase = function(n) {
    var fraction = ['Angle'.'points'];
    var digit = [
        'zero'.'one'.'. '.'叁'.'boss'.'wu'.'land'.'pure'.'捌'.'nine'
    ];
    var unit = [
        ['元'.'万'.'亿'],
        [' '.'pick up'.'or'.'仟']].var head = n < 0 ? 'less' : ' ';
    n = Math.abs(n);
    var s = ' ';
    for (var i = 0; i < fraction.length; i++) {
        s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(Zero /. /.' ');
    }
    s = s || 'the 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 % 10] + unit[1][j] + p;
            n = Math.floor(n / 10);
        }
        s = p.replace(/ (zero). * $/ zero.' ').replace($/ / ^.'zero') + unit[0][i] + s;
    }
    return head + s.replace(/ (zero). * zero yuan /.'元')
        .replace(/ (zero). +/g.'zero')
        .replace(Whole $/ / ^.'zero integer');
};
 
console.log(digitUppercase(12.5)); // Seven thousand six hundred and eighty-two Yuan
console.log(digitUppercase(7682));  Seven thousand six hundred and eighty-two yuan only
console.log(digitUppercase(951434677682.00)); // Nine thousand five hundred and one forty-three million six hundred and seventy-seven thousand six hundred and eighty two only
Copy the code