you probably want to check each letter instead of assuming the user will enter a z. try this:
HTML Code:
<script>
var letter, length, total;
total = 0;
letter = window.prompt('Please enter a letter, z to stop', '');
length = letter.length;
var my_array = letter.split("");
for(var i=0;i<length;i++){
if( my_array[i] == 'a' ){
total++;
}
}
document.write('The number of \'a\'s you have input is ' + total)
</script>
it will only work in IE though ( i think )