formatCurrency()function

formatCurrency(amount: number, currency: string, options?: CurrencyFormatOptions, caller: AnyCaller = formatCurrency): string
ParamType
amountnumber
Amount of money to format. required
currencystring
ISO 4217 currency code, e.g. "USD" or "GBP". required
optionsCurrencyFormatOptions
Formatting options passed through to Intl.NumberFormat.
callerAnyCaller
Function to attribute a thrown error to (defaults to formatCurrency itself). Defaults to formatCurrency
Return
string
Locale-formatted currency string.
Throws
RequiredError
If currency is not a valid currency code.

Format a currency amount (based on the user's browser language settings).

Examples

formatCurrency(1234.5, "USD") // "$1,234.50"