Skip to content

Commit 73e0c61

Browse files
committed
fixed the comparison between a sting and a number to between two strings
1 parent 02245db commit 73e0c61

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ function getOrdinalNumber(num) {
22
let lastDigit = num % 10;
33
let lastTwoDigits = num % 100;
44
if (lastDigit === 1 && lastTwoDigits !== 11) {
5-
// we also can use if (num[-1]===1 && num.slice(-2)!==11)
5+
// we also can use if (num[-1]==="1" && num.slice(-2)!=="11")
66
return num + "st";
77
} else if (lastDigit === 2 && lastTwoDigits !== 12) {
8-
// we also can use if (num[-1]===2 && num.slice(-2)!==12)
8+
// we also can use if (num[-1]==="2" && num.slice(-2)!=="12")
99
return num + "nd";
1010
} else if (lastDigit === 3 && lastTwoDigits !== 13) {
11-
// we also can use if (num[-1]===3 && num.slice(-2)!==13)
11+
// we also can use if (num[-1]==="3" && num.slice(-2)!=="13")
1212
return num + "rd";
1313
} else {
1414
return num + "th";

0 commit comments

Comments
 (0)