Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Latest commit

 

History

History
27 lines (19 loc) · 546 Bytes

number_format.md

File metadata and controls

27 lines (19 loc) · 546 Bytes

numbers/numberFormat

Formats a number to include commas (or any separator) in the thousandths place.

function numberFormat(num: number, separator: string = THOUSANDTHS_SEPARATOR): string

Args

num:number
Number to format.

separator:string
Character that separates thousandths.

Returns

The formatted number.

Examples

import { numberFormat } from 'utils/numbers';

console.log(numberFormat(1234));      // Outputs: 1,234
console.log(numberFormat(1234, '.')); // Outputs: 1.234