Skip to content

Manchester | 26-ITP-Jan | Liban Jama | Sprint 3 | Practice tdd#1198

Open
libanj0161 wants to merge 5 commits intoCodeYourFuture:mainfrom
libanj0161:Sprint-3-2-practice-tdd
Open

Manchester | 26-ITP-Jan | Liban Jama | Sprint 3 | Practice tdd#1198
libanj0161 wants to merge 5 commits intoCodeYourFuture:mainfrom
libanj0161:Sprint-3-2-practice-tdd

Conversation

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

Complete practice tdd.

Questions

No.

@libanj0161 libanj0161 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. Module-Structuring-And-Testing-Data The name of the module. labels Mar 6, 2026
@Theoreoluwa Theoreoluwa 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 Mar 12, 2026
Comment on lines +1 to 6
function repeatStr(str, count) {
if (count < 0) {
throw new Error("invalid count");
}
return str.repeat(count);
}

Choose a reason for hiding this comment

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

This function does not cover all the edge cases as expected to be implemented for the task. Then, your test would not run successfully becauase it's not working according to the task brief. Please, look at it again and read the comments

Copy link
Author

Choose a reason for hiding this comment

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

I realised once reading the task brief and changed it to meet the requirements, thanks for the reminder.

Comment on lines +24 to +42
test("should repeat the string count times", () => {
const str = "hello";
const count = 1;
const repeatedStr = repeatStr(str, count);
expect(repeatedStr).toEqual("hello");
});

// Case: Handle count of 0:
// Given a target string `str` and a `count` equal to 0,
// When the repeatStr function is called with these inputs,
// Then it should return an empty string.

test("should repeat the string count times", () => {
const str = "hello";
const count = 0;
const repeatedStr = repeatStr(str, count);
expect(repeatedStr).toEqual("");
});

Choose a reason for hiding this comment

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

let your function be implemented to suit these test cases

Copy link
Author

Choose a reason for hiding this comment

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

ive altered it, thanks.

Comment on lines +2 to 16
const lastdigit = num % 10;
if (lastdigit === 1) {
return `${num}st`;
}

if (lastdigit === 2) {
return `${num}nd`;
}

if (lastdigit === 3) {
return `${num}rd`;
} else {
return `${num}th`;
}
}

Choose a reason for hiding this comment

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

Your function needs to handle edge cases for other groups of numbers that depend on the last two digits as well. After this, your test should run successfully.

Copy link
Author

Choose a reason for hiding this comment

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

Ive changed the function and added tests to handle edge cases.

Comment on lines 19 to +32

test("should count multiple occurrences of a character", () => {
const str = "house";
const char = "e";
const count = countChar(str, char);
expect(count).toEqual(1);
});

test("should count multiple occurrences of a character", () => {
const str = "playful";
const char = "l";
const count = countChar(str, char);
expect(count).toEqual(2);
});

Choose a reason for hiding this comment

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

Be careful about using a duplicated test description when writing different tests.

Copy link
Author

Choose a reason for hiding this comment

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

i've changed up the description so they are different.

Copy link

@Theoreoluwa Theoreoluwa left a comment

Choose a reason for hiding this comment

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

You've done well, Liban. Look at the comments and make it better. Rooting for you.

@Theoreoluwa Theoreoluwa 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 Mar 12, 2026
@libanj0161 libanj0161 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 13, 2026
@libanj0161 libanj0161 requested a review from Theoreoluwa March 13, 2026 10:36
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. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 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