Skip to content

Commit 1a1df6f

Browse files
committed
Implement countChar in count.js
1 parent 12ce863 commit 1a1df6f

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

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

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

513
module.exports = countChar;

0 commit comments

Comments
 (0)