-
Notifications
You must be signed in to change notification settings - Fork 1
toCurrency
Yousif Al-Raheem edited this page Apr 15, 2020
·
2 revisions
This utility converts a number or a string numeric value (e.g. "1000"
) to a currency formatted string.
console.log(toCurrency(53000.1234));
53,000.12
Param | Type | Description |
---|---|---|
value | number | string |
The value to be formatted |
options? | ToCurrencyOptions | Options to customize the output |
The options parm accepts the following:
option | type | Description |
---|---|---|
separator? | string | The thousand separator. Default is a comma (, ). (e.g. 1👉,👈000) |
decimalSymbol? | string | The decimal point symbol, default is a dot . . 1,000👉.👈12 |
showDecimals? | boolean | Whether to show the decimal places or not, default is true
|
numOfDecimals? | number | The number of decimals places to show, default is 2 (e.g. 1,000.👉12👈) |