Find the character frequency in a given string

Find the character frequency in a given string
0.0 0


my logic is failing to print character occurance in a string

    	<h2>Frequency Calculation</h2>  
		<td>Enter the string:</td>
		<td><textarea cols="10" rows="3 name="string" id="string"></textarea></td>
		<button type="button" id="check" onclick="calculateFrequency()">Check Frequency</button>
		<div id="result"></div>
		<script >

		function calculateFrequency(){

		var str = document.getElementById("string").value;
		var count = 0;
  		for(var i=0; i<str.length; i++) {
  		if(str[i] == str) {
  		//return count;
		   document.getElementById("result").innerHTML = count;


output is attached


What are you checking in the if condition?
If you need to count how many of each character there are, that’s not what does that code.
I am thinking aloud, so to speak, maybe you need some structure to keep track of how many letters are of each one. Then go through the string checking for each letter and sum one if it is the same in the string.
It’s just an idea, to start thinking the problem.
It is useful first try to solve a smaller version “by hand” to get an idea of the problem before beginning to code. Follow each step of the loop to see what’s happening.