Open this example in the interactive library
Source code
const suffix = { one: "st", two: "nd", few: "rd", other: "th" };
const rules = new Intl.PluralRules("en", { type: "ordinal" });
console.log([1, 2, 11, 23].map((n) => n + suffix[rules.select(n)]));
Sample output
[ '1st', '2nd', '11th', '23rd' ]
