Skip to content

Commit 1014714

Browse files
committed
Update: fix countChar function with correct implementation and add example usage
1 parent e2c54d6 commit 1014714

File tree

1 file changed

+8
-2
lines changed
  • Sprint-3/3-mandatory-practice/implement

1 file changed

+8
-2
lines changed
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
function countChar(stringOfCharacters, findCharacter) {
2-
return 5
2+
// return 5; //This will always return 5, regardless of the inputs. So it’s just a placeholder.
3+
return stringOfCharacters.split(findCharacter).length - 1;
34
}
45

5-
module.exports = countChar;
6+
module.exports = countChar;
7+
8+
// console.log(countChar("hello", "l")); // 2
9+
// console.log(countChar("hello world", "o")); // 2
10+
// console.log(countChar("banana", "a")); // 3
11+
// console.log(countChar("mississippi", "i")); // 5

0 commit comments

Comments
 (0)