Skip to content

Instantly share code, notes, and snippets.

@sstur
Last active October 11, 2015 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sstur/3810639 to your computer and use it in GitHub Desktop.
Save sstur/3810639 to your computer and use it in GitHub Desktop.
Format Number with Commas
function formatNumber(val) {
return String(val).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
//formatNumber('1000000') => '1,000,000'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment