Skip to content

Commit b45618a

Browse files
Alex JamshidiAlex Jamshidi
authored andcommitted
updated strings to numbers for === comparisons
1 parent 70ac1d0 commit b45618a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ function getOrdinalNumber(num) {
33
throw new Error("Invalid number");
44
}
55

6-
const lastTwoDigits = num.toString().slice(-2);
7-
const lastDigit = lastTwoDigits.slice(-1);
6+
const lastTwoDigits = Number(num.toString().slice(-2));
7+
const lastDigit = Number(num.toString().slice(-1));
88
if (lastTwoDigits === 11 || lastTwoDigits === 12 || lastTwoDigits === 13) {
99
return `${num}th`;
1010
}

0 commit comments

Comments
 (0)