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 70ac1d0 commit b45618aCopy full SHA for b45618a
1 file changed
Sprint-3/2-practice-tdd/get-ordinal-number.js
@@ -3,8 +3,8 @@ function getOrdinalNumber(num) {
3
throw new Error("Invalid number");
4
}
5
6
- const lastTwoDigits = num.toString().slice(-2);
7
- const lastDigit = lastTwoDigits.slice(-1);
+ const lastTwoDigits = Number(num.toString().slice(-2));
+ const lastDigit = Number(num.toString().slice(-1));
8
if (lastTwoDigits === 11 || lastTwoDigits === 12 || lastTwoDigits === 13) {
9
return `${num}th`;
10
0 commit comments