From 6b9fe6071fc776e6b0d8a18d1c3ccd4643976b29 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Tue, 19 May 2026 00:34:54 +0000 Subject: [PATCH] [Sync Iteration] typescript/line-up/1 --- solutions/typescript/line-up/1/line-up.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 solutions/typescript/line-up/1/line-up.ts diff --git a/solutions/typescript/line-up/1/line-up.ts b/solutions/typescript/line-up/1/line-up.ts new file mode 100644 index 0000000..23ae42e --- /dev/null +++ b/solutions/typescript/line-up/1/line-up.ts @@ -0,0 +1,16 @@ +export function format(name: string, number: number): string { + let ending = "th"; + let numberStr = String(number); + const modOne = number % 10 === 1; + const modTwo = number % 10 === 2; + const modThree = number % 10 === 3; + if ( + (modOne || modTwo || modThree) && + numberStr[numberStr.length - 2] !== "1" + ) { + if (modOne) ending = "st"; + else if (modTwo) ending = "nd"; + else ending = "rd"; + } + return `${name}, you are the ${number}${ending} customer we serve today. Thank you!`; +}