I need to count the number of occurrences of a character in a string.
For example, suppose my string contains:
var mainStr = \"str1,str2,str3,str4\";
And there is:
function character_count(string, char, ptr = 0, count = 0) { while (ptr = string.indexOf(char, ptr) + 1) {count ++} return count }
Works with integers too!