小写数字转换成大写, 只处理到[0 ~ 99]
numberConvertToUppercase(num) {
num = Number(num);
var upperCaseNumber = [
"零",
"一",
"二",
"三",
"四",
"五",
"六",
"七",
"八",
"九",
"十",
"百",
"千"
];
var length = String(num).length;
if (length == 1) {
return upperCaseNumber[num];
} else if (length == 2) {
if (num == 10) {
return upperCaseNumber[num];
} else if (num > 10 && num < 20) {
return "十" + upperCaseNumber[String(num).charAt(1)];
} else {
return (
upperCaseNumber[String(num).charAt(0)] +
"十" +
upperCaseNumber[String(num).charAt(1)].replace("零", "")
);
}
}
}