当前位置:网站首页>JS number capitalization method
JS number capitalization method
2022-04-23 05:38:00 【Sunny warm baby】
js Method of realizing digital capitalization :
capitalMoney(num) {
var strOutput = '';
var strUnit = ' Ten billion, one hundred thousand, one hundred thousand, one hundred and ten yuan ';
num += '0';
var intPos = num.indexOf('.');
if (intPos >= 0) {
num = num.substring(0, intPos) + num.substr(intPos + 1, 1);
}
strUnit = strUnit.substr(strUnit.length - num.length);
for (var i = 0; i < num.length; i++) {
strOutput +=
' One two three four five six seven eight nine '.substr(num.substr(i, 1), 1) +
strUnit.substr(i, 1);
}
return strOutput
.replace(/ Zero angle $/, ' whole ')
.replace(/ zero [ Thousand hundred and ten ]/g, ' zero ')
.replace(/ zero {2,}/g, ' zero ')
.replace(/ zero ([ Billion | ten thousand ])/g, '$1')
.replace(/ zero + element /, ' element ')
.replace(/ 100 million {0,3} ten thousand /, ' Billion ')
.replace(/^ element /, ' zero yuan ');
}
版权声明
本文为[Sunny warm baby]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230536086707.html
边栏推荐
- qt. qpa. plugin: Could not find the Qt platform plugin “xcb“ in ““
- Flutter 新一代图形渲染器 Impeller
- Sea Level Anomaly 和 Sea Surface Height Anomaly 的区别
- Linear sieve method (prime sieve)
- catkin_package到底干了什么
- Golang implements Ping connectivity detection case through exec module
- Why can't V-IF and V-for be used together
- 字符识别easyocr
- SQL语句简单优化
- 可执行程序执行流程
猜你喜欢
创建进程内存管理copy_mm - 进程与线程(九)
QSS, qdateedit, qcalendarwidget custom settings
SQL statement simple optimization
open3d材质设置参数分析
Use of qwbengneview and qwebchannel.
[triangle Yang Hui triangle printing odd even cycle JS for break cycle]
弘玑Cyclone RPA为国金证券提供技术支撑,超200个业务场景实现流程自动化
[untitled] Notepad content writing area
C, class library
Find the number of "blocks" in the matrix (BFS)
随机推荐
C# ,类库
Flutter 新一代圖形渲染器 Impeller
五一劳动节期间什么理财产品会有收益?
Strategy for improving the conversion rate of independent stations | recovering abandoned users
Note: unordered_ Understanding and use of map
弘玑|数字化时代下,HR如何进行自我变革和组织变革?
No.1.#_6 Navicat快捷键
Character recognition easyocr
Data mining -- understanding data
The main difference between pointer and reference
refused connection
Xiuxian real world and game world
Solid contract DoS attack
Sea Level Anomaly 和 Sea Surface Height Anomaly 的区别
Understand the relationship between promise async await
Add two pointers? (legal or illegal)
[the background color changes after clicking a line]
Use of ES6 array
Golang通过exec模块实现Ping连通性检测案例
STL learning notes 0x0001 (container classification)