Skip to content

Commit 5bafddd

Browse files
committed
Update first line to make it more readable - 2-practice-tdd/count.js
1 parent 1f99a76 commit 5bafddd

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
function countChar(stringOfCharacters, findCharacter) {
2-
if (stringOfCharacters.length === 0 || findCharacter.length === 0) return 0;
2+
// 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+
37
let count = 0;
48
for (const char of stringOfCharacters) {
59
if (char === findCharacter) count++;

0 commit comments

Comments
 (0)