Skip to content

Commit 4a012c4

Browse files
committed
Minor cleanup to stub
1 parent 4c7bb04 commit 4a012c4

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
1-
export const format = (name, ordinal) => {
2-
const suffix = getSuffix(ordinal);
3-
4-
return `${name}, you are the ${ordinal}${suffix} customer we serve today. Thank you!`;
5-
};
6-
71
const getSuffix = (number) => {
82
const lastTwoDigits = number % 100;
9-
const lastOneDigit = number % 10;
3+
const lastDigit = number % 10;
104

115
if (lastTwoDigits >= 11 && lastTwoDigits <= 13) {
126
return 'th';
137
}
148

15-
if (lastOneDigit === 1) {
9+
if (lastDigit === 1) {
1610
return 'st';
1711
}
1812

19-
if (lastOneDigit === 2) {
13+
if (lastDigit === 2) {
2014
return 'nd';
2115
}
2216

23-
if (lastOneDigit === 3) {
17+
if (lastDigit === 3) {
2418
return 'rd';
2519
}
2620

2721
return 'th';
2822
};
23+
24+
export const format = (name, number) =>
25+
`${name}, you are the ${number}${getSuffix(number)} customer we serve today. Thank you!`;

0 commit comments

Comments
 (0)