Manchester| 26-ITP-Jan | Ofonime Edak | Sprint 3 | TDD#1226
Open
Ofonimeedak wants to merge 1 commit intoCodeYourFuture:mainfrom
Open
Manchester| 26-ITP-Jan | Ofonime Edak | Sprint 3 | TDD#1226Ofonimeedak wants to merge 1 commit intoCodeYourFuture:mainfrom
Ofonimeedak wants to merge 1 commit intoCodeYourFuture:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
Theoreoluwa
reviewed
Mar 12, 2026
Comment on lines
+50
to
+59
|
|
||
| // case 5: expect number not included in the above case to return th | ||
| test("should return 'th' for numbers ending with 4, 5,6,7,8,9,0", () => { | ||
| expect(getOrdinalNumber(4)).toEqual("4th"); | ||
| expect(getOrdinalNumber(5)).toEqual("5th"); | ||
| expect(getOrdinalNumber(6)).toEqual("6th"); | ||
| expect(getOrdinalNumber(7)).toEqual("7th"); | ||
| expect(getOrdinalNumber(8)).toEqual("8th"); | ||
| expect(getOrdinalNumber(9)).toEqual("9th"); | ||
| expect(getOrdinalNumber(10)).toEqual("10th"); |
There was a problem hiding this comment.
Your tests are fine. But there might be one edge case you are missing out on. You handled 11 and 13; is there one more key group you might have missed?
Theoreoluwa
reviewed
Mar 12, 2026
Comment on lines
+2
to
17
| const numStr = num.toString(); | ||
| const numLength = numStr.length; | ||
| if (numStr[numLength - 2] === "1" && numStr[numLength - 1] === "1") { | ||
| return num + "th"; | ||
| } else if (numStr[numLength - 1] === "1") { | ||
| return num + "st"; | ||
| } else if (numStr[numLength - 2] === "1" && numStr[numLength - 1] === "3") { | ||
| return num + "th"; | ||
| } else if (numStr[numLength - 1] === "3") { | ||
| return num + "rd"; | ||
| } else if (numStr[numLength - 1] === "2") { | ||
| return num + "nd"; | ||
| } else { | ||
| return num + "th"; | ||
| } | ||
| } |
There was a problem hiding this comment.
There is a better arithmetic operator to be used for this function instead of string indexing. This ensures all edge cases are handled in your tests. To ensure code clarity and to avoid string manipulation
Theoreoluwa
reviewed
Mar 12, 2026
Theoreoluwa
left a comment
There was a problem hiding this comment.
Great job so far Edak. Kindly look at the comments made to improve the work done. Well done!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Self checklist
Changelist
I have implemented all function and test cases using the Jest testing framework
I have run the test using npm run test
Sprint-3 TDD on testing of data using the Jest framework