Created
March 1, 2017 02:31
-
-
Save nicholasxjy/b8aefe25f8dcbe6b0416c07060cb9545 to your computer and use it in GitHub Desktop.
format number with commas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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