Skip to content

Instantly share code, notes, and snippets.

@pdokas
Created December 1, 2010 20:55
Show Gist options
  • Save pdokas/724206 to your computer and use it in GitHub Desktop.
Save pdokas/724206 to your computer and use it in GitHub Desktop.
Convert an integer into a comma-delimited string
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