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 5e24460 commit d269accCopy full SHA for d269acc
Sprint-3/2-practice-tdd/count.js
@@ -1,7 +1,17 @@
1
function countChar(stringOfCharacters, findCharacter) {
2
- return stringOfCharacters.split(findCharacter).length - 1;
+ if (
3
+ typeof stringOfCharacters !== "string" ||
4
+ typeof findCharacter !== "string" ||
5
+ findCharacter.length !== 1
6
+ ) {
7
+ return 0;
8
}
9
-module.exports = countChar;
10
+ if (stringOfCharacters.length === 0) {
11
12
+ }
13
14
+ return stringOfCharacters.split(findCharacter).length - 1;
15
+}
16
17
+module.exports = countChar;
0 commit comments