Someone asks a question about digit formatting. For a string of numbers, implement the three-byte expression (for example, 629,200,000.206), and split the number from the back to the front, each three digits into segments, separate them with commas. It is required to use JavaScript to convert the number into an integer first, and then convert it into a three-node subscribe representation, and write a function.
Reference content is as follows: Function format_number (n ){ Var B = parseInt (n). toString (); Var len = B. length; If (len <= 3) {return B ;} Var r = len % 3; Return r> 0? B. slice (0, r) + "," + B. slice (r, len ). match (/\ d {3}/g ). join (","): B. slice (r, len ). match (/\ d {3}/g ). join (","); } |
<Br/> <center> If the page cannot be displayed, press Ctrl + F5 to refresh the page. For more webpage code: <a href = 'HTTP: // www.bkjia.com/'title = "bkjia.com" target = '_ blank'> http://www.bkjia.com/</a> </center>
Tip: the code can be modified before running!