London | 26-ITP-May | Bisrat Tesfay | Sprint 3 | Practice TDD#1510
London | 26-ITP-May | Bisrat Tesfay | Sprint 3 | Practice TDD#1510B3-Bisrat wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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' )
There was a problem hiding this comment.
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.
| return ""; | ||
| } | ||
|
|
||
| if (count > 0) { |
There was a problem hiding this comment.
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
Learners, PR Template
Self checklist
Changelist
I have added tests and functions for the problems.
Questions