We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e448679 commit 5eea892Copy full SHA for 5eea892
Sprint-3/2-practice-tdd/get-ordinal-number.js
@@ -4,13 +4,14 @@ function getOrdinalNumber(num) {
4
const lastTwoDigits = num % 100;
5
if (lastTwoDigits >= 11 && lastTwoDigits <= 13) return num + "th";
6
7
- if (num % 10 === 1) {
+ const lastDigit = num % 10;
8
+ if (lastDigit === 1) {
9
return num + "st";
10
}
- if (num % 10 === 2) {
11
+ if (lastDigit === 2) {
12
return num + "nd";
13
- if (num % 10 === 3) {
14
+ if (lastDigit === 3) {
15
return num + "rd";
16
17
return num + "th";
0 commit comments