Skip to content

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

Open
alizada-dev wants to merge 7 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 7 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

expect(getOrdinalNumber(533)).toEqual("533rd");
})

test("should append 'th' for numbers ending to any numbers expect (1, 2, 3)", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo in the description?

Could consider asking AI to see if the description could be made more concise.

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
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