Created
March 22, 2021 21:20
-
-
Save gnbaron/a3b371bf6ffc0ce5f4ed0fc9595d6b92 to your computer and use it in GitHub Desktop.
format number with commas in js
This file contains hidden or 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(x) { | |
return x.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