I was doing the Smallest Commun Multiple challenge and then I got this weird bug with my code. My code works just fine when I put it in the browser dev tool, but when I try to run from FCC page it always gives me random output, and I’m not allowed to finish the challenge because of that
here is my code
function smallestCommons(arr) {
const minorLimit = Math.min(...arr)
const majorLimit = Math.max(...arr)
let num = majorLimit - 1
let boolFlag = []
do{
boolFlag = []
num++
for(let i = minorLimit; i<= majorLimit; i++){
boolFlag.push(num%i===0?1:0)
}
}while(boolFlag.indexOf(0)>=0)
return num;
}
console.log(smallestCommons([23,18]));
the output, in this case supposed to be 6056820, but instead I just receive random values everytime I change anything on my code from FCC Page code runner.
One more thing: I tried to deactivate the infinity loop protection by writing ```` //noprotect ``` in the beginning of my code but unfortunately it still doesn’t worked