Skip to content

Birmingham | 26-ITP-May | Tobias Amaechina | Sprint 3 | Coursework sprint 3 practice tdd#1501

Open
Tobias-Amaechina wants to merge 17 commits into
CodeYourFuture:mainfrom
Tobias-Amaechina:coursework-sprint-3-practice-tdd
Open

Birmingham | 26-ITP-May | Tobias Amaechina | Sprint 3 | Coursework sprint 3 practice tdd#1501
Tobias-Amaechina wants to merge 17 commits into
CodeYourFuture:mainfrom
Tobias-Amaechina:coursework-sprint-3-practice-tdd

Conversation

@Tobias-Amaechina

Copy link
Copy Markdown

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

I implemented three functions (countChar, getOrdinalNumber, repeatStr) using Test-Driven Development principles. I did wrote comprehensive tests first, then implemented the functions to pass those tests, which aligns with the TDD methodology.

@Tobias-Amaechina Tobias-Amaechina added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 12, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are comprehensive.

// Case 6: All other numbers
// When the number does not fall into any of the above categories,
// Then the function should return a string by appending "th" to the number.
test("should append 'th' for all other numbers", () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a test fails with the message "... all other numbers", it may be unclear what "other numbers" actually refers to.

Could you revise the test description to make it more informative?

Comment on lines +3 to +8
for (let i = 0; i < count; i++) {
result += str;
}
if (count < 0) {
throw new Error("Count must be a non-negative integer");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not perform the check before the for-loop?

Comment on lines +26 to +31
test("should return 0 when character is not found", () => {
const str = "hello";
const char = "x";
const count = countChar(str, char);
expect(count).toEqual(0);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could consider testing a few more samples in this script - higher chance to detect bugs in code.

Also, the original specification did not clearly state whether the character match should be case-sensitive.
Most people would probably assume that it is, but to demonstrate our understanding or clarify the assumption we made,
we could add test cases to convey this. For examples,

  • A case to show that the match is case sensitive
  • A case to show that the function is expected to work also for non-alphabets

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants