title: Timeout error . What is the performance issue in this snippet?
body: <p>I've recently started going through some of Codility coding tests and so far I'am getting 0% on my code performace almost every time.</p>
  
  <p>This one <a href="https://codility.com/programmers/lessons/6-sorting/distinct/" rel="nofollow noreferrer">https://codility.com/programmers/lessons/6-sorting/distinct/</a> is very simple code of finding number of distinct integers in an array.</p>
  
  <p>My code is syntactically correct and works properly but what can i do to optimize the performance ?</p>
  
  <p>This is my code:</p>
  
  <pre><code>function solution(A) {
  
  
      var res = []
      var len = A.length
      for(var i=len;i--;){
          if(!res.includes(A[i])){
              res.push(A[i])
              }
          }
          return res.length
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/8AoxS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8AoxS.png" alt="The performance errors i&#39;m getting from codility"></a></p>