I made the exercise “Smallest Common Multiple”:
function isDiv(num, ini, fim) {
var divFlag = true;
for(var i = ini; i < fim; i++) {
if(num % i !== 0) {
divFlag = false;
break;
}
}
return divFlag;
}
function smallestCommons(arr) {
var bigger = Math.max(arr[0], arr[1]);
var smaller = Math.min(arr[0], arr[1]);
var sc = bigger;
var k = 1;
while(!isDiv(sc, smaller, bigger)) {
sc = bigger * k;
k++;
}
return sc;
}
smallestCommons([23,18]);
It works for all cases, but the last one it doesn’t pass. It is very strange because I’ve tested this code on Online Javascript Editor and it worked for all cases ( https://js.do/code/147068 ). What is happening? Is the problem with FCC ?