File tree Expand file tree Collapse file tree 1 file changed +5
-13
lines changed
Expand file tree Collapse file tree 1 file changed +5
-13
lines changed Original file line number Diff line number Diff line change 11// implement a function countChar that counts the number of times a character occurs in a string
22const countChar = require ( "./count" ) ;
3- // Given a string `str` and a single character `char` to search for,
4- // When the countChar function is called with these inputs,
5- // Then it should:
6-
7- // Scenario: Multiple Occurrences
8- // Given the input string `str`,
9- // And a character `char` that occurs one or more times in `str` (e.g., 'a' in 'aaaaa'),
10- // When the function is called with these inputs,
11- // Then it should correctly count occurrences of `char`.
123
4+ // Scenario 1: Multiple Occurrences
135test ( "should count multiple occurrences of a character" , ( ) => {
14- const str = "aaaaa" ;
15- const char = "a" ;
16- const count = countChar ( str , char ) ;
17- expect ( count ) . toEqual ( 5 ) ;
6+ expect ( countChar ( "aaaaa" , "a" ) ) . toEqual ( 5 ) ;
7+ expect ( countChar ( "sea saw" , "s" ) ) . toEqual ( 2 ) ;
8+ expect ( countChar ( "Arrested Development" , "d" ) ) . toEqual ( 2 ) ;
9+ expect ( countChar ( "* Star * TV *" , "*" ) ) . toEqual ( 3 ) ;
1810} ) ;
1911
2012// Scenario: No Occurrences
You can’t perform that action at this time.
0 commit comments