my logic is failing to print character occurance in a string
<center>
<h2>Frequency Calculation</h2>
<table>
<tr>
<td>Enter the string:</td>
<td><textarea cols="10" rows="3 name="string" id="string"></textarea></td>
</tr>
</table>
<button type="button" id="check" onclick="calculateFrequency()">Check Frequency</button>
<div id="result"></div>
</center>
<script >
function calculateFrequency(){
var str = document.getElementById("string").value;
var count = 0;
for(var i=0; i<str.length; i++) {
if(str[i] == str) {
count++;
}
}
//return count;
document.getElementById("result").innerHTML = count;
}
</script>
</body>
</html>
output is attached