Skip to content

Commit 8706d73

Browse files
committed
fixed if and else if to make the function more cleaner
1 parent 9e5a3cf commit 8706d73

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ function getOrdinalNumber(num) {
33
const lastTwoDigits = num % 100;
44
if (lastDigit === 1 && lastTwoDigits !== 11) {
55
return `${num}st`;
6-
} else if (lastDigit === 2 && lastTwoDigits !== 12) {
6+
}
7+
if (lastDigit === 2 && lastTwoDigits !== 12) {
78
return `${num}nd`;
8-
} else if (lastDigit === 3 && lastTwoDigits !== 13) {
9+
}
10+
if (lastDigit === 3 && lastTwoDigits !== 13) {
911
return `${num}rd`;
10-
} else {
11-
return `${num}th`;
1212
}
13+
return `${num}th`;
1314
}
1415

1516
module.exports = getOrdinalNumber;

0 commit comments

Comments
 (0)