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 0f76821 commit 3716573Copy full SHA for 3716573
Sprint-3/2-practice-tdd/get-ordinal-number.js
@@ -1,5 +1,19 @@
1
function getOrdinalNumber(num) {
2
return "1st";
3
+ const lastDigit = num % 10;
4
+ const lastTwoDigits = num % 100;
5
+ if (lastTwoDigits === 11 || lastTwoDigits === 12 || lastTwoDigits === 13) {
6
+ return num + "th";
7
+ }
8
+ if (lastDigit === 1) {
9
+ return num + "st";
10
+ } else if (lastDigit === 2) {
11
+ return num + "nd";
12
+ } else if (lastDigit === 3) {
13
+ return num + "rd";
14
+ } else {
15
16
17
}
18
19
module.exports = getOrdinalNumber;
0 commit comments