Skip to content

London | 26-ITP-January | Khaliun Baatarkhuu | Sprint 3 | Practice tdd. #1182

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

London | 26-ITP-January | Khaliun Baatarkhuu | Sprint 3 | Practice tdd. #1182
khaliun-dev wants to merge 6 commits intoCodeYourFuture:mainfrom
khaliun-dev:coursework/sprint-3-practice-tdd

Conversation

@khaliun-dev
Copy link

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

Completed all the exercises from Practice TDD.

Questions

None at the moment.

@khaliun-dev khaliun-dev added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 5, 2026
Copy link

@favourO favourO left a comment

Choose a reason for hiding this comment

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

Nice work overall, count and getOrdinalNumber are clear and the tests cover the main cases well. I’ve left 2 comments on repeatStr and it's test to help clean up the final implementation before approval.

//function repeatStr() {
// return "hellohellohello";
function repeatStr(str, count) {
if (count >= 0) return str.repeat(count);
Copy link

Choose a reason for hiding this comment

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

The main logic is working here. Could you make this a little easier to read by expanding the if / else block, and have another look at the error message? At the moment it feels a bit unfinished, so a clearer message would help someone understand what went wrong.

Copy link
Author

Choose a reason for hiding this comment

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

function repeatStr(str, count) {
if (count >= 0) {
return str.repeat(count);
} else {
throw new Error("Invalid argument: 'count' must be a non-negative number.");
}
}

module.exports = repeatStr;


test("should throw an error when count is negative", () => {
expect(() => repeatStr("hello", -1)).toThrow();
});
Copy link

Choose a reason for hiding this comment

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

Nice to see this edge case covered. At the moment the test only checks that an error is thrown. Do you think it would make the test more helpful if it also checked that the error message explains what went wrong?

Copy link
Author

Choose a reason for hiding this comment

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

test("should throw a helpful error when count is negative", () => {
expect(() => repeatStr("hello", -1))
.toThrow("Count cannot be negative");
});

@favourO favourO 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 12, 2026
@khaliun-dev khaliun-dev added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 15, 2026
@khaliun-dev
Copy link
Author

@favourO Thank you for reviewing my PR.

Could you, please, have another look? I think i have addressed both issues you have raised, properly.

Cheers, Khaliun

Copy link

@favourO favourO left a comment

Choose a reason for hiding this comment

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

Nice job,
We are ready to close now.

@favourO favourO 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. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Mar 15, 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