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

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

Answer: 
An easy solution is to loop

```
var count = 0;
for(var i = 0; i < str.length; i ++) {
  if(str.charAt(i) === 't')
    ++count;
}

```

You might also want to use `str.toLowerCase();` if you don't want to be case sensitive.
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');