Smallest Common Multiple - Why this code is not working for the last two input set

Tell us what’s happening:

Your code so far


function smallestCommons(arr) {
  let max = 0, min = 0;
    max = Math.max.apply(Math, arr);
    min = Math.min.apply(Math, arr);
    let lcm = 0
    let flag = false;
    for(lcm=max;;lcm++){
        for(let i = min;i <= max;i++){
            if((lcm%i==0))
                flag = true;
            else{
                    flag = false;       
                    break;
            }
        }
        if(flag == true)
          return lcm;
    }
}


smallestCommons([1,5]);

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/smallest-common-multiple/

not working for the input set [1, 13] should return 360360 and [23, 18] should return 6056820. But its happening only in freecodecamp portal. When I run this in scrimba and jsfiddle its working as expected.

Freecodecamp has an infinite loop protection

You need to make your code more efficient