Skip to content

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.

Example

console.log(toCurrency(1000));

Output

1,000

Properties

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👈)
Clone this wiki locally