Hello everyone! I’m new here.
The if statement doesn’t seem to execute at all with the given condition.
function smallestCommons(arr) {
var max = arr[0] < arr[1] ? arr[1] : arr[0];
var min = arr[0] > arr[1] ? arr[1] : arr[0];
var top = max;
var bool = true;
while(bool === true){
for(var j = min, k = 1, count = 0; j < max; j++, k++){
if(top % max-k === 0){
count++;
}
}
if(count != k)
top += max;
else
bool = false;
}
return top;
}
smallestCommons([1,5]);