Last active
December 20, 2015 21:18
-
-
Save aradnom/6196110 to your computer and use it in GitHub Desktop.
JS for formatting large numbers with commas ('12,345,678'). Uses reduceRight from http://underscorejs.org.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.reduceRight( num.toString().split('').reverse(), function ( stack, next, i ) { return stack + ( i % 3 == 0 && i > 0 ? next + ',' : next ); }, '' ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment