title: How find the length of the longest substring?
body: <p>Need find the length of the longest substring that consists of the same letter. For example, line "aaabbcaaaa" contains four substrings with the same letters "aaa", "bb","c" and "aaaa".</p>
  
  <p>i found two way to do that, but all not so good;</p>
  
  <p>At first way i don't make check previos similar letters here <code>sdsffffse</code>;
  Because i check only current element and second element <code>if(line[i] === line[i+1])</code>.</p>
  
  <p>At second way i fail when i try to check how many <code>aa</code> i found in that string <code>abababaab</code> but in object i add all <code>a</code> letters and length = 5;</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function longRepeat(line) {
      let count = {};
     let letter = [];
    for (let i=0; i&lt;line.length; i++) {
     count[line[i]] = i;
      if(line[i] === line[i+1]){
            letter.push([line[i], line[i+1]])
      }
    }
  
    
  /*
  second way
  for (let x of line) {
      count[x] = ~~count[x] + 1;
   } */
    
    return letter;
  }
  
  console.log(longRepeat('sdsffffse')); f = 4
  console.log(longRepeat('ddvvrwwwrggg')); = 3
  console.log(longRepeat('abababaab')); // last two a = 2</code></pre>
  </div>
  </div>
  </p>