Skip to content

London | 26-ITP-May | Hugh Mills | Sprint 3 | 2. practice tdd - #1607

Open
HM-127BTY wants to merge 2 commits into
CodeYourFuture:mainfrom
HM-127BTY:Sprint-3---2-practice-tdd
Open

London | 26-ITP-May | Hugh Mills | Sprint 3 | 2. practice tdd#1607
HM-127BTY wants to merge 2 commits into
CodeYourFuture:mainfrom
HM-127BTY:Sprint-3---2-practice-tdd

Conversation

@HM-127BTY

@HM-127BTY HM-127BTY commented Aug 5, 2026

Copy link
Copy Markdown

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

Added testing and code, starting with writing a test before adding code.

put in code using "if" function.
@HM-127BTY HM-127BTY added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 5, 2026
@HM-127BTY HM-127BTY changed the title London | 25-ITP-May | Hugh Mills | Sprint 3 | 2. practice tdd London | 26-ITP-May | Hugh Mills | Sprint 3 | 2. practice tdd Aug 5, 2026
@hackertainment hackertainment added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 7, 2026

@hackertainment hackertainment Aug 7, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

semicolon missing in line 8 and line 11.

fun fact: In the original design of JavaScript, there was no semicolon, but it has been added later on - so that nowadays JS programmers generally follow the practice of adding semicolon.

Comment on lines +20 to +33
test("should count multiple occurrences of a character", () => {
const str = "aaa aa";
const char = "a";
const count = countChar(str, char);
expect(count).toEqual(5);
});

test("should count multiple occurrences of a character with random characters", () => {
const str = "ajhyabhaakaka";
const char = "a";
const count = countChar(str, char);
expect(count).toEqual(6);
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The two cases looks quite similar, they both have random characters in the middle of str, and they both start with char, and they both end with char.

Comment on lines 34 to +44
// Scenario: No Occurrences
// Given the input string `str`,
// And a character `char` that does not exist within `str`.
// When the function is called with these inputs,
// Then it should return 0, indicating that no occurrences of `char` were found.
test("should return 0 with no occurrence of the character", () => {
const str ="abcd";
const char = "e";
const count = countChar(str, char);
expect(count).toEqual(0);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There should be one more boundary case making char has no occurrence in str. Can you think of that special case?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think the question requires to also handle 2nd and 3rd etc. Since the question itself may not be quite clear about that, you may clarify in slack channel. Thanks.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if the question requires to also handle 2nd and 3rd etc, then there will be more test cases.

@hackertainment hackertainment left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's a good start, and your written code is generally correct. Just need to design more unique test cases to cover all possible scenarios. Also, there are two more files to complete as well. Keep it up :-)

@hackertainment hackertainment added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Aug 7, 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. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants