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(let i = min;i <= max;i++){
                flag = true;
                    flag = false;       
        if(flag == true)
          return lcm;


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:

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