Smallest Common Multiple: Possible inefficiency/computation bug

Tell us what’s happening:

Today’s a hard day for camper me, this being my second post. So, I was trying to tackle the smallest common multiple exercise, and came up with the solution below:

function smallestCommons(arr) {

  // Find the max/min number in the array
  var max = Math.max(...arr)
  var min = Math.min(...arr)
  var scm = max;
  var mul = 2;

  // Generate array to enumerate
  var enumArr = []
  for (var i = min; i <= max; i++)

  console.log(!enumArr.every( x => 586 % x == 0))


  // Check if in-between numbers divide perfectly
  while (!enumArr.every( x => scm % x == 0))
    console.log("Current scm: " + scm)
    scm = mul * max;

  return scm

smallestCommons([1, 13]) 

Sure enough, it passes all but the last two tests. Looking at the console output for the “Current scm” log, it is a different number every time and since all my variables are initialized, I can’t help but wonder if my solution is inefficient and is giving the interpreter a hard time. Do you know what’s happening? Because it looks correct and I’m pulling my hair!

Your browser information:

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

Link to the challenge:

You may be triggering the infinite loop protection, it does stop a loop from running if it is taking too much time - you may need to refactor your code so that your loop needs less time