title: Count the number of times appears of each word
body: <p>How to count the number of times appears of each word in a text introduced by the user? I have this for now: </p>
  
  <pre class="lang-js prettyprint-override"><code>function print() {
      text1 = texto.value;                                                     
      var sim = /\s+/gi;                                                      
      var word= texto.value.trim().replace(sim, ' ').split(' ').length;   
      var space= texto.value.split(" ").length - 1;                          
      alert("Number of spaces: " + (space) + "\nNumber of words: " + (word));
      document.getElementById("show").innerHTML = text.value;
  }
  
  countWords(document.getElementById("IDTextAreal").value());
  </code></pre>
  
  <p>If the user introduces the string "Hello my name is Hello" the script show:</p>
  
  <pre class="lang-none prettyprint-override"><code>Hello: 2, my: 1, name: 1, is: 1.
  </code></pre>