Skip to content

Instantly share code, notes, and snippets.

@dkordik
Created September 6, 2011 21:37
Show Gist options
  • Save dkordik/1199047 to your computer and use it in GitHub Desktop.
Save dkordik/1199047 to your computer and use it in GitHub Desktop.
Add comma separators to numbers
function addCommasToNumber(n) {
return n.toString().split('').reverse().join('').match(/(.{1,3})/g).join(',').split('').reverse().join('');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment