Javascript curriculum intermediate script lcm - multiple

type or paste code here

function smallestCommons(arr) {
   let multiple=lcm(arr[0],arr[1]);
   for( let j=arr[0]+1;j<arr[1];j++){
     multiple=(lcm(multiple,arr[j]));
     console.log(multiple);
   }
   return multiple;
}
function lcm(arg1,arg2){
    let max = arg1 > arg2 ?  arg1 : arg2;
    let i = max, bool= true;
    while( bool === true ){
          if(i%arg1===0 && i%arg2===0) 
          {
                 return i;
          }  else {
                 i = i + max;
           }
    }
}

smallestCommons ([1,5]);

Why isn’t my code working…? please help me.

Your code is going into infinite loop, while(bool===true) is never going to be false.
Need to find GCM first then you can find LCM.

const lcm = (...arr) => {
  const gcd = (x, y) => (!y ? x : gcd(y, x % y));
  const _lcm = (x, y) => (x * y) / gcd(x, y);
  return [...arr].reduce((a, b) => _lcm(a, b));
};
lcm(1,5);