Created
May 5, 2024 11:20
-
-
Save edrisranjbar/b06aa68c3a996a0742153f8fc2e8c5fe to your computer and use it in GitHub Desktop.
Add commas to currency in JavaScript
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
const 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