Skip to content

Commit 74d5e9f

Browse files
author
russom
committed
Function for first test case fir checking numbers ending with st implemented.
1 parent 0e19677 commit 74d5e9f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
function getOrdinalNumber(num) {
2-
return "1st";
2+
const lastDigit = num % 10;
3+
const lastTwoDigits = num % 100;
4+
if (lastDigit === 1 && lastTwoDigits !== 11) {
5+
return `${num}st`;
6+
}
7+
return `${num}th`;
38
}
49

510
module.exports = getOrdinalNumber;

0 commit comments

Comments
 (0)