Skip to main content

utils.tothousand

Home > @nipem/utils > toThousand

toThousand() function

format a number to thousand points

Signature:
export declare function toThousand(n: number, digits?: number): string;

Parameters

ParameterTypeDescription
nnumbernumber
digitsnumber(Optional) The number of digits to appear after the decimal point
Returns:

string

formatted string

Example

// digits default 0
toThousand(1234.5678) // 1,234.5678
// set digits to 2
toThousand(1234.5678, 2) // 1,234.57