Last active
September 7, 2021 13:16
-
-
Save russellf9/b5199c42e07091928f97e950414d636a to your computer and use it in GitHub Desktop.
JS - Utility to format currency (in this case USD)
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 as currency | |
export function formatCurrency(amount) { | |
return new Intl.NumberFormat(`en-US`, { | |
style: "currency", | |
currency: "USD", | |
minimumFractionDigits: 2, | |
}).format(amount); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment