Skip to content

Commit 3fbf92e

Browse files
committed
Implement the function countChar Sprint-3/2-practice-tdd/count.js
1 parent b31a586 commit 3fbf92e

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
function countChar(stringOfCharacters, findCharacter) {
2-
return 5
2+
//count the occurrences of the char in the string
3+
// Make it case insensitive
4+
let countChar = 0;
5+
for (const char of stringOfCharacters) {
6+
if (char.toLowerCase() === findCharacter.toLowerCase()) {
7+
countChar++;
8+
}
9+
}
10+
return countChar;
311
}
412

513
module.exports = countChar;

0 commit comments

Comments
 (0)