Skip to content

Commit 6c0be54

Browse files
updated the function to handle empty strings
1 parent 5d5d095 commit 6c0be54

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Sprint-3/2-practice-tdd/count.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
function countChar(stringOfCharacters, findCharacter) {
22
let char = 0;
3+
if (stringOfCharacters === 0){
4+
return 0
5+
}
36
for(let i = 0;i <= stringOfCharacters.length - findCharacter.length;i++){
47
if ( findCharacter.length === 0 || stringOfCharacters === 0){
58
return 0;

0 commit comments

Comments
 (0)