Skip to content

Commit fc349ab

Browse files
committed
implement count function
1 parent edb4fe4 commit fc349ab

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

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

512
module.exports = countChar;

0 commit comments

Comments
 (0)