toOrdinal
Adds the respective ordinal suffix (-st, -nd, -rd or -th) to a number.
Usage
ts
import { toOrdinal } from '@screaming/utils'
toOrdinal(1)
// '1st'
toOrdinal(2)
// '2nd'
toOrdinal(3)
// '3rd'
toOrdinal(4)
// '4th'
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
Type Definitions
ts
/**
* @param n - The number.
* @returns The number with the ordinal suffix appended.
*/
export declare function toOrdinal(n: number): string
1
2
3
4
5
2
3
4
5