Is there a simple way to check how many times a character appears in a String?
You could remove any other character in the string and check the length:
str.replace(/[^a]/g, "").length
Here it is counted how many as are in str.
a
str