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.
```
<button onclick="alert(countCharacter('abcdea', 'a'));"> Test! </button>

<script type="text/javascript">
    function countCharacter(sample, characterToFind) {
        var result = 0;

        for(i = 0;i<sample.length;i++) {
            if(sample[i] === characterToFind) {
                result++;
            }
        }

        return result;
    }
</script>

```