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);
    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;


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:

Unfortunately, your current algorithm is just not efficient enough to pass that last test. The test suite has a feature which protects against potential infinite loops. When calls against your solution take too long, this feature gets triggered even if you do not have an infinite loop. Once this feature is triggered, your script just stop executing.

See if you can rewrite your solution with a more efficient algorithm.

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++){
//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;