Hey there,
I just wanted to know what is wrong with my approach.
I was inspired by the pixelsorting algorithm I saw once by Daniel Shiffman,
where one for-loop loops through every element of the array, and for every element it loops through the rest.
I wrote this to check if there are non-unique elements in the arry and log a 'true'-statement for every time it matches.
let arr = [1, 2, 3, 1, 3];
console.log(arr);
for (i = 0; i++; i < arr.length) {
for (j = i; j++; j < arr.length) {
if (arr[i] == arr[j]) {
console.log('true');
}
}
}
But it won't fire, so there has to be some flaw in my thinking process. Maybe someone sees the error?
Cheers and have a nice evening
Fabian
Created at: 2019/08/31 19:41; Updated at: 2022/09/09 15:24
The question is resolved.