title: Function to count duplicate characters in a string
body: <p>I am trying to write a function which finds all unique characters in a provided string.</p>
  
  <p>I'd like the function to return the results in the following format:</p>
  
  <pre><code>removeDuplicates('th#elex_ash?') -&gt; {unique: 'aehlstx', duplicates: 2}
  </code></pre>
  
  <p>So far I have come up with the following attempted solution:</p>
  
  <pre><code>function removeDuplicates(str){
      var unique ="";
      for (var i=0; i&lt;str.length; i++){
          if(unique.indexOf(str[i]) == -1){
              unique += str[i];
          }
      }
      unique = unique.replace(/[&amp;\/\\#,_+()$~%.'":*?&lt;&gt;]/g, '');
      return unique.split('').sort().join('');
  
  
  
  
  }
  
  console.log(removeDuplicates('aaabbbac'));
  console.log(removeDuplicates('a'));
  console.log(removeDuplicates('th#elex_ash?'));
  </code></pre>