Skip to content

Commit

Permalink
Fix pluralization edge case for teens
Browse files Browse the repository at this point in the history
  • Loading branch information
ky28059 committed Aug 30, 2024
1 parent 092cadc commit ec9e58e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions util/strings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function pluralize(num: number) {
if (num % 10 === 1) return `${num}st`;
if (num % 10 === 2) return `${num}nd`;
if (num % 10 === 3) return `${num}rd`;
if (num % 10 === 1 && num !== 11) return `${num}st`; // 21st, but not 11th
if (num % 10 === 2 && num !== 12) return `${num}nd`; // 32nd, but not 12th
if (num % 10 === 3 && num !== 13) return `${num}rd`; // 63rd, but not 13th
return `${num}th`
}

0 comments on commit ec9e58e

Please sign in to comment.