Skip to content

Commit 1443cbf

Browse files
committed
completed the No occurrences Scenario test
1 parent 62ef41d commit 1443cbf

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Sprint-3/3-mandatory-practice/implement/count.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ function countChar(stringOfCharacters, findCharacter) {
1010

1111
return count;
1212
}
13-
console.log(countChar("ahmad", "a")); // example usage should return 2.
14-
console.log(countChar("hello", "h")); // example usage should return 1;
13+
console.log(countChar("aAaAaAaAa", "a")); // example usage should return 5.
1514

1615
module.exports = countChar;

Sprint-3/3-mandatory-practice/implement/count.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@ test("should count multiple occurrences of a character", () => {
2222
// And a character char that does not exist within the case-sensitive str,
2323
// When the function is called with these inputs,
2424
// Then it should return 0, indicating that no occurrences of the char were found in the case-sensitive str.
25+
26+
test("should return 0 when character does not exist in the string", () => {
27+
const str = "aaaaa";
28+
const char = "b";
29+
const result = countChar(str, char);
30+
expect(result).toEqual(0);
31+
});
32+
// the above test cases are for the countChar function that counts the number of times a character occurs in a string.
33+
// this function should return 0 because the character `b` does not exist in the string "aaaaa".

0 commit comments

Comments
 (0)