Created
April 26, 2024 11:23
-
-
Save renventura/6dfdea10257add53b56ba786e4b0142f to your computer and use it in GitHub Desktop.
Javascript code to format a number to USD currency
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 formatUSD = (value) => { | |
return new Intl.NumberFormat( | |
'en-US', | |
{ | |
style: 'currency', | |
currency: 'USD' | |
} | |
).format(value); | |
} | |
// $50.00 | |
formatUSD(50); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment