Practice

Count Letter Function

MEDIUMProcedures & Functions7 marks

Write function CountLetter(Text, Target) that returns how many times the character Target appears in Text. The check must be case-insensitive (A and a both count).

Input: A string, then a single-character string. Output: The count.

Example:

Input:  Banana
        a
Output: 3
Premium is coming soon. All grading features are currently unlocked.

Sample Test Cases

Test 1: Three a/A letters
Inputs: Banana, a
Expected: 3
Test 2: Uppercase target still matches
Inputs: Banana, A
Expected: 3