This article mainly introduces the sample code for converting JavaScript integer strings to amount data. For more information, see.
The Code is as follows:
Function zhen (str ){
Var arr_1 = ["", "\ u62fe", "\ u4f70", "\ u4edf", "\ u4e07", "\ u4ebf"], arr_2 = ["", "\ u4e07", "\ u4ebf"];
Var maskstr = arr_1.slice (1). join ("");
Var arr2 = ["\ u96f6", "\ u58f9", "\ u8d30", "\ u53c1", "\ u8086", "\ u4f0d", "\ u9646 ", "\ u67d2", "\ u634c", "\ u7396"];
Var arr3 = new Array;
Var arr = str. split ("");
Arr. reverse ();
Var _ step _ = 4;
Var _ index _ = 0;
Var int1 = 0, int2 = 0;
// Var
For (var I = 0; I <arr. length; I ++ ){
_ Index _ = I;
Int1 = _ index _ % _ step _;
Int2 = parseInt (_ index _/_ step _);
If (int2> 0 & int1 = 0 ){
If (maskstr. indexOf (arr3 [arr3.length-1])! =-1 ){
Arr3.pop ();
}
Arr3.push (arr_2 [int2]);
}
If (arr [I]> 0 ){
If (int1> 0 ){
Arr3.push (arr_1 [int1]);
}
}
Arr3.push (arr2 [arr [I]);
}
Arr3.reverse ();
Return arr3.join ("");
}
Test:
Zhen ('20140901 ');
-> "Tens of thousands of employees have joined the Competition"