Hello,everyone!
Will you please help me to understand why my code doesn’t pass the test for value[1,13] and [23,18] on Free Code Camp? This code works fine on my browser and giving me correct answer.
here is my code…
function smallestCommons(arr) {
let max=Math.max(...arr);
let min=Math.min(...arr);
let val=max;
let result;
while(true){
let b=[];
for (var i=min;i<=max;i++){
if(val%i===0){
b.push('true');
}
else{
b.push('false');
}
}
if (b.indexOf('false')===-1){
result=val;
break;
}
else{
val=val+1;
continue;
}
}
return result;
}
console.log(smallestCommons([23,25]));
thanks in advance.