Skip to content

Instantly share code, notes, and snippets.

@LarsEliasNielsen
Created October 23, 2013 10:38
Show Gist options
  • Save LarsEliasNielsen/7116327 to your computer and use it in GitHub Desktop.
Save LarsEliasNielsen/7116327 to your computer and use it in GitHub Desktop.
Format number with commas.
function formatNumber(unformattedNumber) {
return unformattedNumber.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment