Created
October 3, 2023 16:17
-
-
Save dazecoop/62571b574efa44aca817484cb1c8c99d to your computer and use it in GitHub Desktop.
Vanilla JS number format, useful for currency formatting. Similar to PHP's number_format()
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
// Format number to X decimal places. | |
function numberFormat(number, minimumFractionDigits = 0) { | |
return new Intl.NumberFormat('en', { minimumFractionDigits }).format(number); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment