hello campers ,I don’t know why I got everthing correct in google chrome console , but in FCC console the last two tests didn’t pass , is this a bug?
function smallestCommons(arr) {
var max=Math.max.apply(null,arr);
var min=Math.min.apply(null,arr);
let Range=[];
// find the range
for (let i=min;i<=max;i++){
Range.push(i);
}
//find the first and last arguments
let firstNum=arr[0]; //1
let secondNum=arr[1]; //5
for (let i=0;i<Infinity;i++){
let stopLoopFirst=0;
let stopLoopSecond=0;
firstNum+=arr[0];
secondNum+=arr[1];
for(let i =0;i<Range.length;i++){
let firstNumDivision=firstNum/Range[i];
let secondNumDivision=secondNum/Range[i];
if(firstNumDivision % 1===0){
stopLoopFirst+=1;
}
else if(secondNumDivision % 1===0){
stopLoopSecond+=1;
}
}
if(stopLoopFirst===Range.length){
return firstNum;
}
else if(stopLoopSecond===Range.length){
return secondNum;
}
}
}
smallestCommons([1, 13]);