function smallestCommons(arr) {
if(arr[1]<arr[0]){
var temp = arr[0];
arr[0] = arr[1];
arr[1] = temp;
}
var match = 1;
var found = false;
var c = 0;
while(found==false){
for(i=arr[0];i<=arr[1];i++){
if(match%i==0){
c++;
}
}
if(c==(arr[1]-arr[0]+1)){
found = true;
}else{
match++;
c = 0;
}
}
console.log(match);
return match;
}
When I run this the first 3 checks pass but the other two don’t, while showing different values for match each time. Why does this happen? What am I doing wrong?