Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated the code to cover the test cases
  • Loading branch information
alexandru-pocovnicu committed Jun 18, 2025
commit 5889529855d17827b7470e83b8c0c82277a198bf
18 changes: 17 additions & 1 deletion Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
function getOrdinalNumber(num) {
return "1st";
if (isNaN(num)) {
return NaN;
}
if(num>=11 && num<=13){
return num+"th"
}

if(num===1){
return num+"st"
}
if (num === 2) {
return num + "nd";
}
if (num === 3) {
return num + "rd";
}
return (num)+"th"
}

module.exports = getOrdinalNumber;