Last active
August 4, 2022 06:31
-
-
Save sethdavis512/a42b53f72512f3a6d9d7ea2d13b40bba to your computer and use it in GitHub Desktop.
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
function toDollar(n) { | |
const numWithCommas = n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
return `$${numWithCommas}`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment