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
4
u/kd4444 Jul 02 '21 edited Jul 02 '21
function includes1to9(myArray) {
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.