London | ITP-JAN-2026 | Said Fayaz Sadat | Sprint 3 | coursework/sprint-3/practise-tdd#1222
London | ITP-JAN-2026 | Said Fayaz Sadat | Sprint 3 | coursework/sprint-3/practise-tdd#1222fayaz551 wants to merge 7 commits intoCodeYourFuture:mainfrom
Conversation
|
@cjyuan created PR for practice-tdd |
cjyuan
left a comment
There was a problem hiding this comment.
This exercise also expects the three functions to be implemented after you have prepared the tests.
| expect(getOrdinalNumber(4)).toEqual("4th"); | ||
| expect(getOrdinalNumber(5)).toEqual("5th"); |
There was a problem hiding this comment.
Could consider testing more samples, ideally covering all digits that should be appended with "th".
There was a problem hiding this comment.
Added the full implementation of getOrdinalNumber.
The function now correctly handles all cases:
Tests for All other numbers append "th".
There was a problem hiding this comment.
You could also describe the numbers in this category as "numbers not ending with 1, 2 and 3" or "numbers ending with 0, 4-9".
There was a problem hiding this comment.
I will change the description for it
|
Can you also revise the description in the Changelist section of the PR description? |
…sitive and non-alphabet characters
| if (count === 0) { | ||
| return ""; | ||
| } | ||
|
|
||
| if (count === 1) { | ||
| return str; | ||
| } | ||
|
|
||
| let result = ""; | ||
| for (let i = 0; i < count; i++) { | ||
| result += str; | ||
| } |
There was a problem hiding this comment.
This code works.
Note: There is also a string's built-in method we can use to simplify this code.
No change is needed.
| expect(getOrdinalNumber(4)).toEqual("4th"); | ||
| expect(getOrdinalNumber(5)).toEqual("5th"); |
There was a problem hiding this comment.
You could also describe the numbers in this category as "numbers not ending with 1, 2 and 3" or "numbers ending with 0, 4-9".
Learners, PR Template
Self checklist
Changelist
This PR covers the Sprint 3 Practice TDD coursework. I have separated this into its own branch to meet the sprint requirements and ensure the GitHub validation bot passes.
Questions
n/a