title: How to count the letters in a text with Javascript?
body: <p>I am currently trying to write a ''web application'' that has a simple text area inside, in which I want the letters of the text written to be pointed out.</p>
  
  <p>For example, if I write:</p>
  
  <p>''How old are you? I am 19 years old''</p>
  
  <p>I need a code to tell me how many 'A's and 'Y's and 'D's (and all letters of the alphabet from 0-26) are used in this sentence when I press a button on a HTML/ CSS page.</p>
  
  <p>Could you please tell me what I must write into my .JS file and what I should write into my .HTML file to do this with a click of a button when something is written in the  ?</p>
  
  <p>I hope my explanation was detailed enough. Thanks!</p>
  
  <p>Edit (I'm very sorry for the problems I caused) - What I have done so far looks like this:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;link rel="stylesheet" type="text/css" href="theme.css"&gt;
  &lt;meta charset="utf-8"&gt; 
  
  &lt;script src="test.js" type="text/javascript"&gt;&lt;/script&gt;
  
  &lt;div class='header'&gt;
  Al.Fa.Be
  &lt;/div&gt;
  
  &lt;div class='yaz'&gt;
  &lt;textarea&gt;&lt;/textarea&gt;
  
  &lt;/div&gt;
  
  &lt;div class='description'&gt;
  &lt;a href='http://www.google.com'&gt;Ara&lt;/a&gt;
  &lt;/div&gt;
  
  &lt;div class='description2'&gt;
  &lt;input id="clickMe" type="button" value="Hesapla" onclick="doFunction();" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>CSS: </p>
  
  <pre><code>body{
  background:white;
  }
  
  selection{
  background:#CCC;
  }
  
  #clickMe{
  background:#CCC;
  border:1px solid #333;
  
  }
  
  .header{
  font-size:70px;
  font-weight:bold;
  font-family:Arial;
  color:#333;
  margin-left:580px;
  padding-top:200px;
  }
  
  textarea{
  width:1210px;
  height:40px;
  color:black;
  margin-top:20px;
  margin-left:100px;
  padding-left:10px;
  padding-top:10px;
  font-size:18px;
  font-family:Arial;
  }
  
  .description{
  background:#f2f2f2;
  padding:6px;
  width:50px;
  text-align:center;
  border:1px solid #ddd;
  font-family:Arial;
  margin-left:620px;
  margin-top:20px;
  font-size:14px;
  }
  
  .description a{
  color:#555;
  text-decoration:none;
  }
  
  .description2{
  background:#f2f2f2;
  padding:6px;
  width:60px;
  text-align:center;
  border:1px solid #ddd;
  font-family:Arial;
  margin-left:750px;
  margin-top:-30px;
  font-size:14px;
  }
  
  .description2 a{
  color:#555;
  text-decoration:none;
  }
  
  .yaz{
  color:white;
  }
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>// Input name. Count number of alphabets a-z
  class program                                                          
  {
      public static void main(String[] args) 
      {
          String name = args[0];
          int count[] = new int[29];
          int i,p;
          int n = name.length();
          name = name.toUpperCase();
          char c;
          for (i=0; i&lt;29; i++) 
          {
              count[i] = 0;   
          }
          for (i=0; i&lt;n; i++) 
          {
              c = name.charAt(i);
              p = (int) c;
              count[p-65]++;
          }
          for (i=0; i&lt;29 ; i++) 
          {
              if (count[i] &gt;0) 
              {
                  System.out.println((char)(i+65) + " occurs " + count[i] + " times");
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>PS: Please remember that I really suck at this and I need to know how to do this in a specific way.</strong></p>