Formats a number with thousands separators, English/US style (comma thousands separator, period decimal point) -- not locale-aware, see numbersToWords's own docs for why.
Number to format.
Optional
Number of decimal places to round/pad to. Omit to preserve the input's natural precision.
The formatted number, or the shared invalid-input message for anything that isn't a finite number.
formatNumber(1234567); // '1,234,567'formatNumber(1234567.89); // '1,234,567.89'formatNumber(1234.5, { decimals: 2 }); // '1,234.50'formatNumber(-1234.5); // '-1,234.5' Copy
formatNumber(1234567); // '1,234,567'formatNumber(1234567.89); // '1,234,567.89'formatNumber(1234.5, { decimals: 2 }); // '1,234.50'formatNumber(-1234.5); // '-1,234.5'
Formats a number with thousands separators, English/US style (comma thousands separator, period decimal point) -- not locale-aware, see numbersToWords's own docs for why.