const myCleanedArray = myArray.filter(num m => num !== 0);
const mySet = new Set(myCleanedArray);
return mySet.size === myCleanedArray.length;
}
Can’t get the formatting quite right but something like this should work - the set will remove any duplicated values, so if its size doesn’t match the length of the input array, it will return false.
4
u/kd4444 Jul 02 '21
Maybe try using a set to check the length against the original array, to see if anything was removed (meaning that there was a duplicate)?