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 a61f9b1 commit 2a422f5Copy full SHA for 2a422f5
Sprint-3/2-practice-tdd/count.test.js
@@ -1,5 +1,16 @@
1
// implement a function countChar that counts the number of times a character occurs in a string
2
const countChar = require("./count");
3
+
4
+function countChar(stringOfCharacters, findCharacter) {
5
+ let count = 0;
6
+ for (let char of stringOfCharacters) {
7
+ if (char === findCharacter) count++;
8
+ }
9
+ return count;
10
+}
11
12
+module.exports = countChar;
13
14
// Given a string str and a single character char to search for,
15
// When the countChar function is called with these inputs,
16
// Then it should:
0 commit comments