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 02245db commit 73e0c61Copy full SHA for 73e0c61
1 file changed
Sprint-3/2-practice-tdd/get-ordinal-number.js
@@ -2,13 +2,13 @@ function getOrdinalNumber(num) {
2
let lastDigit = num % 10;
3
let lastTwoDigits = num % 100;
4
if (lastDigit === 1 && lastTwoDigits !== 11) {
5
- // we also can use if (num[-1]===1 && num.slice(-2)!==11)
+ // we also can use if (num[-1]==="1" && num.slice(-2)!=="11")
6
return num + "st";
7
} else if (lastDigit === 2 && lastTwoDigits !== 12) {
8
- // we also can use if (num[-1]===2 && num.slice(-2)!==12)
+ // we also can use if (num[-1]==="2" && num.slice(-2)!=="12")
9
return num + "nd";
10
} else if (lastDigit === 3 && lastTwoDigits !== 13) {
11
- // we also can use if (num[-1]===3 && num.slice(-2)!==13)
+ // we also can use if (num[-1]==="3" && num.slice(-2)!=="13")
12
return num + "rd";
13
} else {
14
return num + "th";
0 commit comments