We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cafb60d commit eafa0bfCopy full SHA for eafa0bf
1 file changed
Sprint-3/2-practice-tdd/count.js
@@ -1,5 +1,10 @@
1
function countChar(stringOfCharacters, findCharacter) {
2
- return 5
+ 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;
8
}
9
10
module.exports = countChar;
0 commit comments