-
-
Save tobidsn/e07e59de6fc4d19043167c83d949f6d8 to your computer and use it in GitHub Desktop.
JS Regex: Adds thousands separator to a number.
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
// Adds the thousands separator | |
function numberWithThousands(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