Smallest Common Multiple final condition is not pass

Tell us what’s happening:
last condition is not passing ([23,18])
why is that please help.?

Your code so far

function smallestCommons(arr) {
  var ar=[];
  var gcd =1;
  var b=[];
  var higher;
  var lower;
  var flag;
  if (arr[0]<arr[1]){
    higher = arr[1];
    lower = arr[0];
    
  }
  else {
    higher = arr[0];
    lower = arr[1];
  }
  
  for(var i=lower;i<=higher;i++){
    gcd = gcd * i;
    ar.push(i);
  }
  
 
  for (var k=1; k<gcd;k++){
     for ( var j=lower; j<=higher; j++){
       if ( k%j==0){
         flag += 1; 
       }
       else {
         flag = 0;
       }
     }
     if (flag == higher){
         break;       

     }
  }
  return k;
  
}


smallestCommons([1,5]);

Your browser information:

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

Link to the challenge:
https://www.freecodecamp.org/challenges/smallest-common-multiple

 if (flag == higher){
     break;       

 }

This works well if the smallest number is 1, but otherwise this condition will never be meet. That’s because from your code, the maximum value that flag can have is ( higher - lower + 1 ), thus, if lower > 1 implies that higher > flag.