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..751ca47 --- /dev/null +++ b/solutions/typescript/line-up/1/line-up.ts @@ -0,0 +1,19 @@ +export function format(name: unknown, number: unknown): unknown { + let stringVersion: string = ``; + let postfix: string = ``; + if (typeof number === `number`) { + stringVersion = number.toString(); + postfix = stringVersion[stringVersion.length - 1]; + } + if (postfix === `1` && stringVersion !== `11`) { + postfix = `${stringVersion}st`; + } else if (postfix === `2` && stringVersion !== `12` && stringVersion !== `112`) { + postfix = `${stringVersion}nd`; + } else if (postfix === `3` && stringVersion !== `13`) { + postfix = `${stringVersion}rd`; + } else { + postfix = `${stringVersion}th`; + } + + return `${name}, you are the ${postfix} customer we serve today. Thank you!`; +} \ No newline at end of file