• Approach by looping through

Question related to mission Non-unique Elements


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];

for (i = 0; i++; i < arr.length) {
    for (j = i; j++; j < arr.length) {
            if (arr[i] == arr[j]) {



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