I am having some trouble understanding why this code is not passing all of the tests:
function smallestCommons(arr) {
console.log();
arr.sort(function(a, b){return b-a});
console.log(arr)
let found = false;
let num = 1;
let arrRange = arr[0] - arr[1] + 1;
let count = 1;
console.log(arrRange);
while(found == false) {
for (let i = arr[0]; i >= arr[1]; i--) {
if (num % i == 0) {
count++;
if (count == arrRange) {
found = true;
console.log(num);
return(num);
}
} else {
count = 0;
break;
}
}
num++;
}
return arr;
}
smallestCommons([2,10]);