Skip to content

Commit eafa0bf

Browse files
committed
Complete countChar function to make all jest tests pass in 2-practice-tdd/count.js
1 parent cafb60d commit eafa0bf

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
function countChar(stringOfCharacters, findCharacter) {
2-
return 5
2+
if (stringOfCharacters.length === 0 || findCharacter.length === 0) return 0;
3+
let count = 0;
4+
for (const char of stringOfCharacters) {
5+
if (char === findCharacter) count++;
6+
}
7+
return count;
38
}
49

510
module.exports = countChar;

0 commit comments

Comments
 (0)