Skip to content

Commit d8fd187

Browse files
committed
completed the function now it should count how many char in a string
1 parent 113d089 commit d8fd187

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
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; // this replaces 'return 5'
39
}
410

511
module.exports = countChar;

0 commit comments

Comments
 (0)