Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions solutions/typescript/line-up/1/line-up.ts
Original file line number Diff line number Diff line change
@@ -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!`;
}