Skip to content

Commit d36de13

Browse files
committed
Mod-2-Sprint-3-2-practice-tdd exercise 1 done
1 parent 3372770 commit d36de13

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Sprint-2/Project-CLI-Treasure-Hunt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 4374e4e6b862b0a110e806b6115f3f6b3c22b26a

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
function countChar(stringOfCharacters, findCharacter) {
2-
return 5
2+
let count = 0;
3+
for (const char of stringOfCharacters) {
4+
if (char === findCharacter) {
5+
count++;
6+
}
7+
}
8+
return count;
39
}
410

5-
module.exports = countChar;
11+
module.exports = countChar;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ test("should count multiple occurrences of a character", () => {
2222
// And a character `char` that does not exist within `str`.
2323
// When the function is called with these inputs,
2424
// Then it should return 0, indicating that no occurrences of `char` were found.
25+
test("should return 0 when a character does not occur in the string", () => {
26+
const str = "aaaaa";
27+
const char = "z";
28+
const count = countChar(str, char);
29+
expect(count).toEqual(0);
30+
});

0 commit comments

Comments
 (0)