title: Find first recurring character using javascript
body: <blockquote>
  <p>Input: array=[2,5,1,2,3,5,1,2,4]</p>
  <p>Output return 2</p>
  <p>Input: array=[2,1,1,2,3,5,1,2,4]</p>
  <p>Output return 1</p>
  <p>Input array=[2,3,4,5]</p>
  <p>Output return undefined</p>
  </blockquote>
  <p>I run my code on <a href="https://repl.it/repls/DistinctConcreteMatch" rel="nofollow noreferrer">repl.it</a> and it always return undefined.</p>
  <p>Is there any improve ways to let undefined disappear?</p>
  <p>Also how to return undefined in third input?</p>
  <p>What i try in my JS:</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 FirstRecurringCharacter(arr){
  for (i = 0; i &lt; arr.length; i++) {
    if (arr.indexOf(arr[i]) !== i) {
      console.log(arr[i]);
      break;
    }
  }
  };
     
   FirstRecurringCharacter([2,5,1,2,3,5,1,2,4])//should return 2
     
   FirstRecurringCharacter([2,1,1,2,3,5,1,2,4])//should return 1
     
   FirstRecurringCharacter([2,3,4,5])//should rerturn undefined</code></pre>
  </div>
  </div>
  </p>