Skip to content

London|ITP-Jan-2026| Ping Wang | Sprint 3 | 2-Practice TDD#1009

Closed
pathywang wants to merge 7 commits intoCodeYourFuture:mainfrom
pathywang:sprint-3/2--practive-tdd
Closed

London|ITP-Jan-2026| Ping Wang | Sprint 3 | 2-Practice TDD#1009
pathywang wants to merge 7 commits intoCodeYourFuture:mainfrom
pathywang:sprint-3/2--practive-tdd

Conversation

@pathywang
Copy link
Copy Markdown

@pathywang pathywang commented Feb 21, 2026

  • 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

After i redo my prep and create file for test.js and test.jest.je to check i did everything OK, i completed 6 tests and jest tests ok.

Questions

none

@github-actions

This comment has been minimized.

@pathywang pathywang added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 21, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 21, 2026
@pathywang pathywang added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 21, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 21, 2026
@pathywang pathywang added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 21, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 21, 2026
@github-actions

This comment has been minimized.

@pathywang pathywang changed the title London|ITP-Jan-2026|Ping Wang|Spirnt3 |Sprint 3-2 practive tdd London|ITP-Jan-2026|Ping Wang|Spirnt 3 |Sprint 3-2 practive tdd Feb 21, 2026
@pathywang pathywang added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 21, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 21, 2026
@github-actions

This comment has been minimized.

@pathywang pathywang changed the title London|ITP-Jan-2026|Ping Wang|Spirnt 3 |Sprint 3-2 practive tdd London|ITP-Jan-2026|Ping Wang|Spirnt 3 |Practice TDD Feb 21, 2026
@pathywang pathywang added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 21, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 21, 2026
@github-actions

This comment has been minimized.

@pathywang pathywang changed the title London|ITP-Jan-2026|Ping Wang|Spirnt 3 |Practice TDD London|ITP-Jan-2026| Ping Wang | Spirn -3 | Practice TDD Feb 21, 2026
@github-actions

This comment has been minimized.

@pathywang pathywang changed the title London|ITP-Jan-2026| Ping Wang | Spirn -3 | Practice TDD London|ITP-Jan-2026| Ping Wang | Sprint 3 | 2-Practice TDD Feb 21, 2026
@pathywang pathywang added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 21, 2026
@hkavalikas hkavalikas self-requested a review March 1, 2026 16:47
@hkavalikas hkavalikas 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 1, 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.

Let's keep the file tidy without console logs unless it's the aim of the exercise.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's keep the file tidy without console logs unless it's the aim of the exercise.

Comment on lines +2 to +3
lastDigit = num % 10;
lastTwoDigits = num % 100;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

While this, in theory, works, without a declaration keyword, they become implicit global variables, which could cause bugs. How can we fix that?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's keep the file tidy without console logs unless it's the aim of the exercise.

// When the repeatStr function is called with these inputs,
// Then it should throw an error, as negative counts are not valid.
test("should repeat the string negative times", () => {
expect(repeatStr("celebration", -5)).toEqual("invalid count");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Throwing an error and returning a string is quite different, how can we fix this test?

function repeatStr(str,count) {
if (count>0) return str.repeat(count)
if (count===0) return ""
if (count<0) return"invalid count"
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 test is asking for an error to be thrown when the count is negative but we are instead returning a string, how can we address that?

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

Choose a reason for hiding this comment

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

What would happen if we were to call str.repeat(0) ? Give it a shot, and once you do, how can we tweak this function slightly to save ourselves from one more if statement?

@hkavalikas hkavalikas 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 1, 2026
@pathywang
Copy link
Copy Markdown
Author

pathywang commented Mar 1, 2026 via email

@hkavalikas
Copy link
Copy Markdown

Absolutely @pathywang , feel free to close this PR, open a new one and assign me as a reviewer.

@pathywang
Copy link
Copy Markdown
Author

pathywang commented Mar 2, 2026 via email

@hkavalikas
Copy link
Copy Markdown

Hey @pathywang , amazing work. I approved the other PR with one small comment; let's close this one as it's a duplicate.

Re; assigning someone as a reviewer, assuming you have the necessary permissions, you can use the Reviewers component at the top right and select someone by name. Having said that, I wouldn't worry too much if you can't use it, as it's definitely out of scope for this exercise. Once again, amazing work!

Screen Shot 2026-03-02 at 07 55 58 am

@pathywang pathywang closed this Mar 2, 2026
@pathywang
Copy link
Copy Markdown
Author

pathywang commented Mar 2, 2026 via email

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