Skip to content

Commit 6951135

Browse files
Refactor getOrdinalNumber function for clarity
1 parent ffb67e9 commit 6951135

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Sprint-3/2-practice-tdd/get-ordinal-number.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ function getOrdinalNumber(num) {
44
return num + "th";
55
}
66
let lastDigit = num % 10;
7-
// umbers ending with 1
7+
88
if (lastDigit === 1) {
99
return num + "st";
1010
}
11-
// numbers ending with 2
11+
1212
if (lastDigit === 2) {
1313
return num + 'nd';
1414
}
15-
// numbers ending with 3
15+
1616
if (lastDigit === 3) {
1717
return num + 'rd';
1818
}
19-
//any other number
19+
2020
return num + 'th';
2121
}
2222

0 commit comments

Comments
 (0)