Count Instances of a Character in a String

Published by supafly in

Create a function that takes a character and a string as arguments and returns the number of times the character is found in the string.

Examples

CharCount('a', "edabit") ➞ 1

CharCount('c', "Chamber of secrets") ➞ 1

CharCount('b', "big fat bubble") ➞ 4

Notes

Your output must be case-sensitive (see second example).

Watch a quick demo on how Edabit works.