Smallest Common Multiple bug?

Smallest Common Multiple bug?
0

#1

Tell us what’s happening:

Why this code does not pass the challenge?

Your code so far


function smallestCommons(arr) {
 let min=Math.min(arr[0],arr[1]);
 let max=Math.max(arr[0],arr[1]);
 let newArr=[];

 for(let i=min;i<=max;i++){
  newArr.push(i)
 }
var res = 0;
  var l = 1;
  var n;

  // Run code while n is not the same as the array length.
  do {
    res = newArr[0] * l * newArr[1];
    for (n = 2; n < newArr.length; n++) {
      if (res % newArr[n] !== 0) {
        break;
      }
    }

    l++;
  } while (n !== newArr.length);

  return res;
}



smallestCommons([1,13]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0.

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


#2

your code worked perfectly for me. I think you should reset the code and refresh the browser and just copy it back in and run it. Hopefully it works that time.