Skip to content

Cape Town | 26-ITP-Jan | Pretty Taruvinga | Sprint 3 | Practice TDD#1133

Open
Pretty548 wants to merge 12 commits intoCodeYourFuture:mainfrom
Pretty548:coursework/sprint-3-practice-tdd
Open

Cape Town | 26-ITP-Jan | Pretty Taruvinga | Sprint 3 | Practice TDD#1133
Pretty548 wants to merge 12 commits intoCodeYourFuture:mainfrom
Pretty548:coursework/sprint-3-practice-tdd

Conversation

@Pretty548
Copy link

@Pretty548 Pretty548 commented Mar 2, 2026

Learners, PR Template

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

In this PR I implemented the required functions using the TDD approach.

Wrote tests first before implementing the functions
Made the tests pass by writing the correct logic
Refactored the code to improve readability and structure
Ensured all tests pass successfully using Jest

Questions

I would appreciate feedback on:

Whether my TDD workflow is correct
Code structure and readability
Test quality and naming

@github-actions

This comment has been minimized.

2 similar comments
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Pretty548 Pretty548 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Structuring-And-Testing-Data The name of the module. labels Mar 2, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 2, 2026
@github-actions

This comment has been minimized.

2 similar comments
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@Pretty548 Pretty548 marked this pull request as draft March 2, 2026 17:09
@Pretty548 Pretty548 marked this pull request as ready for review March 2, 2026 17:09
@Pretty548 Pretty548 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 2, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 2, 2026
@Pretty548 Pretty548 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 2, 2026
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

Functions look good.

Tests could use some improvement.

Also, can you remove any unused code and unnecessary comments from the files to keep them cleaner? They make the code less readable.

Comment on lines +36 to +41
test("should be case sensitive", () => {
const str = "Hello World";
const char = "H";
const count = countChar(str, char);
expect(count).toEqual(1);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice touch to to show match is case sensitive.

Could also consider a case to show that the function is expected to work also for non-alphabets.

return "1st";
const suffixes = ["th", "st", "nd", "rd"];
const v = num % 100;
return num + (suffixes[(v - 20) % 10] || suffixes[v] || suffixes[0]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Fancy!

To check your understanding:
Suppose v is 97, then both
97 % 10 = 7
(97-20) % 10 = 77 % 10 =7

Why not express line 4 as return num + (suffixes[v % 10] || suffixes[v] || suffixes[0]);?

// Case 4: All other numbers
// When the number does not end with 1, 2, or 3 (or ends with 11, 12, or 13),
// Then the function should return a string by appending "th" to the number.
test("should append 'th' for all other numbers", () => {
Copy link
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.
Can you revise the test description to make it more informative?

Copy link
Contributor

Choose a reason for hiding this comment

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

There is only one test in this script.

@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 Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Structuring-And-Testing-Data The name of the module. 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