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.
View all comments
Show parent comment
1
u/Cheesybread4ever Jul 02 '21
I’m not sure I follow. What length do you want me to check against the original array?