title: JS Find indices of duplicate values in array if there are more than two duplicates
body: <p>I'm creating coordinate plane Three in a row game so I have to find out if there are three numbers of the same value in the array BUT WITHOUT sorting array because the array represents the x-coordinates of the points added to the coordinate plane during the game...
  For example, let's say that I've added 6 points to the coordinate plane with x-coordinates stored in next array:</p>
  
  <pre><code>var arr = [2,2,3,2,7,3];
  </code></pre>
  
  <p>I need the loop that will count only the occurrences of the value 2 because the number 2 occurs 3 times in array, so the output should be a new array (for example array named indices) with the exact indices of nmb 2 occurrences in arr... </p>
  
  <pre><code>indices = [0,1,3]
  </code></pre>
  
  <p>The loop should therefor "reset" when comes to the end of the arr if the number of occurrences of some value is less than 3...</p>
  
  <p>I've tried the next code, but it doesn't work like I've described above because it counts the number of occurrences of the number 3 as well... so, it won't "reset" if value count is less than 2...</p>
  
  <pre><code>var arr = [2,2,3,2,7,3];
  var index = [];
  var count = 0;
  var current;
  for(var i = 0;i&lt;arr.length;i++){
      current = arr[i];
      //-------------------------------
      for(var j=i+1;j&lt;arr.length;j++){
          if(arr[j]===current){
              count++;
              index.push(j);
              //+++++++++++
              if(j===arr.length-1){
                  if(count&lt;2){
                      count = 0;
                      index = [];
                      i++;
                  }
                  else{
                      index.unshift(i);
                      break;
                  }
              }
              //+++++++++++
          }
      }
      //-------------------------------
  }
  alert(index);
  </code></pre>
  
  <p>Thanks for any help or advice...</p>
  
  <p>Aleksandra</p>