Displaying the characters and their frequency pls help me for project only :)
<!DOCTYPE HTML> <html> <body> <p>Click the button to Decompress.</p> <button onclick="myFunction()">Try it</button> <br/> <br/>Enter Text: <input type="text" id="txt1" name="text1"> <p id="demo"></p> <p id ="demo2"></p> <br> <button onClick="getFrequency(string)"> Show the Characters</button> <script> function myFunction() { var y = document.getElementById("txt1").value; document.getElementById("demo").innerHTML = y.length*8; } //function for displaying the frequency of the characters function getFrequency(string) { var x = document.getElementById("txt1").value; document.getElementById("demo2").innerHTML = freq; var freq ={} for (var i=0; i<x.length;i++) { var character = x.charAt(i); if (freq[character]) { freq[character]++; } else { freq[character] = 1; } } return freq; } </script> </body> </html>