Skip to content

Commit f774e8d

Browse files
committed
Implement character counting logic in countChar function
1 parent 951157c commit f774e8d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
function countChar(stringOfCharacters, findCharacter) {
2-
return 5
2+
let count = 0;
3+
4+
for (let char of stringOfCharacters) {
5+
if (char === findCharacter) {
6+
count++;
7+
}
8+
}
9+
10+
return count;
311
}
412

513
module.exports = countChar;
14+

0 commit comments

Comments
 (0)