Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How does jQuery convert lowercase numbers to uppercase and add thousands to lowercase numbers?
How does jQuery convert lowercase numbers to uppercase and add thousands to lowercase numbers?
Give you an idea:

1, take out number and assign it to num.

2,num num =。 parseFloat( num)。 to fixed(2(2); Convert to floating-point type, and keep 2 decimal places;

3. Use var tmp = num.split (""); Split numbers into arrays

4. Loop the tmp array and use swtich to convert each number into the corresponding capitalization.

5. Flatten the array and return it to the uppercase output area.

Lowercase plus one thousandth can be counted from the decimal point to the left, and a comma is added to every 3 digits.

Or split the number into arrays, judge the decimal point position, look to the left, push a comma every three, and then assemble the array.