Count Occurrences

STRING

Problem

Given a string inputString and a character c, return the number of times c occurs in inputString.

Examples

countOccurrences("abc", "a") // 1 // The letter 'a' appears once in the string "abc". countOccurrences("Mississippi", "s") // 4 // The letter 's' appears four times in the string "Mississippi".
Loading...