Skip to content

Commit b7cdfee

Browse files
committed
feat: implement character counting function in count.js
1 parent 19452c4 commit b7cdfee

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
function countChar(stringOfCharacters, findCharacter) {
2-
return 5
2+
3+
let count = 0;
4+
5+
for (i = 0; i < stringOfCharacters.length; i++) {
6+
if (stringOfCharacters[i] === findCharacter) {
7+
count += 1;
8+
}
9+
}
10+
11+
return count;
312
}
413

514
module.exports = countChar;
15+

0 commit comments

Comments
 (0)