Skip to content

Instantly share code, notes, and snippets.

@nicholasxjy
Created March 1, 2017 02:31
Show Gist options
  • Save nicholasxjy/b8aefe25f8dcbe6b0416c07060cb9545 to your computer and use it in GitHub Desktop.
Save nicholasxjy/b8aefe25f8dcbe6b0416c07060cb9545 to your computer and use it in GitHub Desktop.
format number with commas
export function numberWithCommas(num) {
return num.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