Smallest Common Multiple(i cant pass)

Tell us what’s happening:

i just cant pass this test

Your code so far


function smallestCommons(arr) {
  // return arr;
  let found = false;
  let multiple = 0;
  let integer = Math.max(...arr);
  while(!found){
    let divisible = true;
    for(let i = Math.min(...arr); i <= Math.max(...arr); i++){
      // console.log(`${integer} % ${i} = ${integer % i}`)
      if(integer % i != 0) divisible = false;
    }
    if(divisible === true) {
      found = true;
      multiple = integer;
    };
    integer += Math.max(...arr);
  }
  return multiple;
  console.log(multiple)
}


smallestCommons([23,18]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

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

ok thanks i will try…

ok i get it now

function smallestCommons(arr) {
const min = Math.min(…arr);
const max = Math.max(…arr);
const numSet = [];
//set of numbers
for(let i = min; i <= max; i++){
numSet.push(i)
}
//get multiple of two number
function getMultiple(a, b){
let suggestion = a;
let c = suggestion % b;
while (c != 0){
suggestion += a;
c = suggestion % b;
}
return suggestion;
}
const multiple = numSet.reduce((multiple, num) => {
return getMultiple(multiple, num)
}, max)

return multiple;
}

smallestCommons([1,5]);