title: How do you look through arrays more efficiently? Javascript
body: <p>I've been doing a lot of the practise tests on codility and though all my solutions work, they always have hidden stress tests which include massive arrays, the following code for example needs to take array A and find the lowest positive number missing from the sequence.</p>
  <p>e.g:  given A = [1, 3, 6, 4, 1, 2], the function should return 5. 5 is the value of <code>i</code> which increments in the loop.  Function returns whenever index <code>i</code> is not found in array.</p>
  <p>It works correctly but codility tested it with a 1-100,000 array and it timed out at the 6 second limit. most of my codes on the practise tests tend to fail for the same reason. Any help greatly appreciated.</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>console.log(solution([1, 3, 6, 4, 1, 2]));
  function solution(A) {
      let i = 0
      for (i = 1; i &lt;= A.length ; i++){
          if(A.includes(i) == false){
              return i
          }
      }
      return i
  }</code></pre>
  </div>
  </div>
  </p>