title: How to proper use reduce() javascript/typescript
body: <ol>
  <li>I try to solve task below with reduce() and actually the result is ok. But I don't know how to use acc in reduce() instead of acc1 or indexMax.</li>
  <li>How to apply typescript to this task.</li>
  </ol>
  <p>The task:
  <strong>Find first word with max repeated letter count.</strong> For example <strong>rrrtygggg</strong> and <strong>ttbvfddjklyyyaseqq</strong> - the winner is <strong>rrrtygggg</strong>.
  If sequence has no repeated letters return 'false'.
  Count only letters, ignor digits and special chars.</p>
  <p>Here is my solution.
  Also I need to keep time complexity not higher than n. The most important part for me is <code>reduce()</code> and <code>acc</code>.</p>
  <pre><code>const maxLettersInString =(str)=&gt;{
          let acc1={};
          let indexMax;
          let ind=0;
          let n=0;
  
          const newStr = str.replace(/[^a-z\s]/gi,'')
          const arr = str.split(' ');
          if(arr.length===0) return false;
          const arr1 = newStr.split('');
  
          const result = arr1.reduce((acc,x)=&gt;{
              if(x!==' '){
                  acc1[x] ? acc1[x]++ : acc1[x] = 1;
                  if(acc1[x]&gt;n) n=acc1[x], indexMax=ind;
              }
              if(x===' ') acc1={}, ind+=1;
              else return indexMax;
          })
  
          if(n===1) return false
          return arr[result]
      }
  console.log(maxLettersInString('fdsJJHHBldfkfd +=dfsfds tbrlllLLtrbtrbrLL666667777LLtlllllll----- fdsfs66df7758 tRbrerbrrtRR'));
  </code></pre>