Count Wordula

Task 1

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.

Extension:

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.
About CDB 361 Articles
Self-Employed Software Developer, Spark, Property Management, Hobby Forestry, Ex-Teacher, Engineering - Wood, Metal, Electrics & Computers. Outdoors - Walk, Cycle, Kitesurf,

Be the first to comment

Leave a Reply

Your email address will not be published.


*


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