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 1f99a76 commit 5bafdddCopy full SHA for 5bafddd
1 file changed
Sprint-3/2-practice-tdd/count.js
@@ -1,5 +1,9 @@
1
function countChar(stringOfCharacters, findCharacter) {
2
- if (stringOfCharacters.length === 0 || findCharacter.length === 0) return 0;
+ // return 0 if either the string or character is empty
3
+ const hasNoInput =
4
+ stringOfCharacters.length === 0 || findCharacter.length === 0;
5
+ if (hasNoInput) return 0;
6
+
7
let count = 0;
8
for (const char of stringOfCharacters) {
9
if (char === findCharacter) count++;
0 commit comments