This function takes a number as a parameter and formats it as a currency string based on the specified options.
Parameters
currency
(number, required): the currency code to use for formatting the number.locale
(string, optional): the locale to use for formatting the currency. If not provided, the "en" locale will be used.minDecimal
(number, optional): the minimum number of decimal places to include in the formatted currency string. If not provided, the default minimum of 2 decimal places will be used.maxDecimal
(number, optional): the maximum number of decimal places to include in the formatted currency string. If not provided, the default maximum of 2 decimal places will be used.
Examples
format-currency(123456.789, currency="USD")
# returns "$123,456.79"
format-currency(123456.789, currency="EUR", minDecimal=3, maxDecimal=3)
# returns "€123,456.789"
format-currency(123456.789, currency="JPY", minDecimal=0, maxDecimal=0)
# returns "¥123,457"
format-currency(123456.789, currency="CAD", locale="fr-CA")
# returns "123 456,79 $CA"