ts-humanize / ordinal
ordinal(
x,options?):string
Defined in: ordinals/ordinals.ts:29
Returns the ordinal representation of a number (e.g., 1st, 2nd, 3rd, 4th). Always rounds to the nearest whole number.
number
The number to convert to its ordinal string.
OrdinalOptions
Options for additional formatting such as commifying.
string
The ordinal string for the given number.
ordinal(1); // "1st"
ordinal(22); // "22nd"
ordinal(-13); // "-13th"
ordinal(1234, { commify: true }); // "1,234th"
ordinal(12.7); // "13th"
ordinal(1003.35, { commify: true }); // "1,003rd"