Count Wordula

Write a function called CountOccurences which takes two arguments.

The first is a single-character string and the second is a string of any length. The function should return the number of times that the character occurs in the second argument.  

For example: CountOccurences(“a”,“Bananarama”) should return the integer 5.


For a challenge: add a third argument of type Boolean. If this argument is TRUE then the search is case-sensitive, if it is FALSE then the search ignores case. It should default to FALSE. If the language used by the centre allows it, this third argument could be optional – defaulting to TRUE.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.