Question: Assuming:
str value = 'This is some text';

I want to count how many 't' occurrences, how to do that?

Answer: 
```
var sValue = 'This is some text';
var tCount = sValue.split("t").length - 1;
alert("t appears " + tCount + " times");

```

If you want to count occurrences of all letters, you better use one loop as shown in the other answers.
Several ways to do this...

```
function countChar(str, searchChar) {
   var num=0;
   for (var i=0; i<str.length; ++i) {
      if (str[i] == searchChar)
         ++num;
   }
   return num;
}

```

use like:

numt = countChar('This is some text', 't');