I write my bike to remove the same elements of the array. As if during the output to the console, duplicates are not caught, that is, everything is displayed as it should (1, 11, 2, 4, 5, 3). But at the same time, nothing falls into the resulting res array. Help fix
var res = []; var a = [1, 1, 11, 2, 4, 2, 5, 3, 1]; var N = a.length; for (i = 0; i < N; i++) { f = 1; for (j = 0; j < N; j++) if (a[i] == a[j] && i != j) { f = 0; break; } if (f == 1){ console.log(a[i]); //в консоле(1,11,2,4,5,3) res.push(a[i]) // в итоговом массиве 1,1,11,2,4,2,5,3,1 -----что не верно } } }