Created
December 1, 2010 20:55
-
-
Save pdokas/724206 to your computer and use it in GitHub Desktop.
Convert an integer into a comma-delimited string
This file contains 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
function insertCommas(n, delim) { | |
var n = ''+n, l = n.length, | |
delim = delim || ','; | |
return (l > 3) ? insertCommas(n.substr(0, l-3)) + delim + n.substr(l-3) : n; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment