Skip to content

London | 26-ITP-May | Bisrat Tesfay | Sprint 3 | Practice TDD#1510

Open
B3-Bisrat wants to merge 2 commits into
CodeYourFuture:mainfrom
B3-Bisrat:Sprint-3/2-practice-tdd
Open

London | 26-ITP-May | Bisrat Tesfay | Sprint 3 | Practice TDD#1510
B3-Bisrat wants to merge 2 commits into
CodeYourFuture:mainfrom
B3-Bisrat:Sprint-3/2-practice-tdd

Conversation

@B3-Bisrat

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

I have added tests and functions for the problems.

Questions

@B3-Bisrat B3-Bisrat added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 14, 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.

We can also add some other test cases to make sure that our function behaves as we want in edge cases, for example what happens when the str is empty? or has spaces , or is it case sensitive ( finding 'a' in 'Apple' )

@tiakavousi tiakavousi Jul 15, 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.

I like that you're handling invalid inputs! To make it even clearer, what do you think about moving the error check to the very top.
This is called 'failing fast', it catches bad inputs immediately and keeps the rest of the code cleaner.

@tiakavousi tiakavousi 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 Jul 15, 2026
return "";
}

if (count > 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.

Your approach here is very creative!
But as a fun challenge: subtracting 1 each time means a count of 10,000 will crash the call stack.
How can this be improved so that the function handles high numbers safely?
We could think about a 'divide and conquer' recursive approach, OR the less exciting (but safer) approach of using a standard for loop, as you probably know

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