formatCurrency
This helper function is used to format a currency value for a given locale. Intl.NumberFormat
is used under the hood to format the currency.
Import
Parameters
formatCurrency
accepts a single object as a parameter with the following properties:
amount
- amount
-
number
bigint
The amount to format.
options
See the Intl.NumberFormatOptions page for more information on what can be passed in.
- options?
-
Intl.NumberFormatOptions
The options to format the currency.
locale
See the locales page for more information on what can be passed in.
- locale?
-
Intl.LocalesArgument
The locale to format the currency.
Default:
en-US
Usage
Default
The above would yield the following output:
With Options
Here is an example with options:
The above would yield the following output:
Returns
The formatted currency value as a string.