@@ -23,20 +23,20 @@ function countChar(stringOfCharacters, findCharacter) {
2323}
2424
2525// Examples
26- countChar ( "hello" , "l" ) ; // returns 2
27- countChar ( "javascript" , "a" ) ; // returns 2
28- countChar ( "hello" , "z" ) ; // returns 0
29- countChar ( "null" , "" ) ; // "Error: The character to count must be a single character."
30- countChar ( "" , "a" ) ; // "Error: The string cannot be empty."
31- countChar ( "hello" , "ll" ) ; // "Error: The character to count must be a single character."
32- countChar ( "hipopotamos' make wonderful pets" , "o" ) ; // returns 3
33- countChar ( "hipopotamos" , "p" ) ; // returns 1
34- countChar ( "hipopotamos' are a friendly animal" , "t" ) ; // returns 1
35- countChar ( "hipopotamos" , "x" ) ; // returns 0
36- countChar ( "Pneumonoultramicroscopicsilicovolcanoconiosis" , "i" ) ; // returns 6
37- console . log ( countChar ( "null" , "" ) ) ;
38- console . log ( countChar ( "" , "a" ) ) ;
39- console . log ( countChar ( "hello" , "ll" ) ) ;
40- countChar ( null , "a" ) ; // "Error: The string cannot be empty ."
26+ console . log ( countChar ( "hello" , "l" ) ) ; // Expected: 2
27+ console . log ( countChar ( "javascript" , "a" ) ) ; // Expected: 2
28+ console . log ( countChar ( "hello" , "z" ) ) ; // Expected: 0
29+ console . log ( countChar ( "null" , "" ) ) ; // Expected: "Error: The character to count must be a single character."
30+ console . log ( countChar ( "" , "a" ) ) ; // Expected: "Error: The string cannot be empty."
31+ console . log ( countChar ( "hello" , "ll" ) ) ; // Expected: "Error: The character to count must be a single character."
32+ console . log ( countChar ( "hipopotamos' make wonderful pets" , "o" ) ) ; // Expected: 3
33+ console . log ( countChar ( "hipopotamos" , "p" ) ) ; // Expected: 1
34+ console . log ( countChar ( "hipopotamos' are a friendly animal" , "t" ) ) ; // Expected: 1
35+ console . log ( countChar ( "hipopotamos" , "x" ) ) ; // Expected: 0
36+ console . log ( countChar ( "Pneumonoultramicroscopicsilicovolcanoconiosis" , "i" ) ) ; // Expected: 6
37+ console . log ( countChar ( "null" , "" ) ) ; // Expected: "Error: The character to count must be a single character."
38+ console . log ( countChar ( "" , "a" ) ) ; // Expected: "Error: The string cannot be empty."
39+ console . log ( countChar ( "hello" , "ll" ) ) ; // Expected: "Error: The character to count must be a single character."
40+ console . log ( countChar ( null , "a" ) ) ; // Expected: "Error: The input string cannot be null or undefined ."
4141
4242module . exports = countChar ;
0 commit comments