-
Notifications
You must be signed in to change notification settings - Fork 1
toCurrency
Yousif Al-Raheem edited this page Jan 20, 2020
·
2 revisions
This utility converts a number or a string numeric value (e.g. "1000"
) to a currency formatted string.
console.log(toCurrency(1000));
1,000
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 comma (, ). (e.g. 1👉,👈000) |
radix? | string | The radix symbol separating the number from cents. 1,000👉.👈12 |
noCents? | boolean | Whether to display cents or not. Default is true . |
decimals? | number | The decimal number of digits. Default is 2. (e.g. 1,000.👉12👈) |