javascript count occurrences of substring in string