Skip to content

Commit c1a84c9

Browse files
committed
Implement function to check character occurrence in a string.
1 parent 4b9ad62 commit c1a84c9

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎practice-tdd/count.js‎

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

0 commit comments

Comments
 (0)