[javascript] Count the number of occurrences of a character in a string in Javascript