function three(arr){ return arr.filter((el, i)=> { var s = 0; while (i--) { if (el == arr[i]) s++; if (s > 2)return false } return s == 2; }); }