Function currencyFormatter

  • Converts a number into a formatted currency value.

    Parameters

    • val: number

      The number to be formatted as currency.

    • options: NumberFormatOptions = {}

      An object with some or all of the properties of Intl.NumberFormatOptions.

    Returns string

    • The formatted value as a string.

    Example

    console.log(currencyFormatter(1234567890.1997)); // ₹1,23,45,67,890.20
    console.log(currencyFormatter(1234567890, {locales: "en-US", currency: "USD", maximumFractionDigits: 0})); // $1,234,567,890

    Link

    Reference - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options

Generated using TypeDoc