UNPKG

@azizbecha/strkit

Version:

strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.

15 lines (14 loc) 462 B
/** * Converts a number into its ordinal form as a string (e.g., 1"1st", 2"2nd"). * * @param num - The number to convert to its ordinal form. * @returns The ordinal form of the number as a string. * * @example * toOrdinal(1); // Output: "1st" * toOrdinal(2); // Output: "2nd" * toOrdinal(3); // Output: "3rd" * toOrdinal(11); // Output: "11th" * toOrdinal(101); // Output: "101st" */ export default function toOrdinal(num: number): string;