Skip to content

West Midlands | 26-Jan-ITP | Fida H Ali Zada | Sprint 3 | TDD#1134

Open
alizada-dev wants to merge 11 commits intoCodeYourFuture:mainfrom
alizada-dev:coursework/sprint-3-practice-tdd
Open

West Midlands | 26-Jan-ITP | Fida H Ali Zada | Sprint 3 | TDD#1134
alizada-dev wants to merge 11 commits intoCodeYourFuture:mainfrom
alizada-dev:coursework/sprint-3-practice-tdd

Conversation

@alizada-dev
Copy link

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

Wrote tests before the code that will make them pass.

@alizada-dev alizada-dev added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 2, 2026
Comment on lines +25 to +30
test(`should return 0 for no occurances of 'char' in 'str'`, () => {
const str = "code your future";
const char = "x";
const count = countChar(str, char);
expect(count).toEqual(0);
})
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Could consider testing more samples.

  • Could consider testing these cases:

    • 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

Copy link
Author

Choose a reason for hiding this comment

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

Thank you, sir, for the review. I fixed all the suggested changes.

if (count >= 0) {
return str.repeat(count);
} else {
throw new Error("");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not include an informative error message to inform the caller what the error is?

test("should throw an error", () => {
const str = "responsibility";
const count = -5;
// const repeatedStr = repeatStr(str, count);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why keep the code as comment on line 48?

@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
@alizada-dev alizada-dev added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 10, 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.

Changes look good. Well done.

Comment on lines +32 to +35
test(`in case sensitive case, should also return the number of character in the string`, () => {
expect(countChar("Code Your Future!", "Y")).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.

Could include a lower case y in the input to demonstrate and ensure the match is indeed case-sensitive.

Comment on lines +44 to +46
test(`should return the count for unusual characters`, () => {
expect(countChar("code& $future £your", "$")).toEqual(1)
}) No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there is a more common name that describes characters that are neither alphabets nor digits, than "unusual characters".

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. 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

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants