Smallest Common Multiple - possible bug

Hi everyone, this code is failing on test cases [1, 13] and [23, 18]. I’ve tested it on two other Node editors and it works. Would appreciate some help.

function smallestCommons(arr) {
  arr = arr.sort((a, b) => a - b);
  const range = [];

  for(let i = arr[0]; i <= arr[1]; i++) {
  const product = range.reduce((acc, curr) => acc * curr);
  for(let i = range[range.length - 1] + 1; i <= product; i++) {
    if(range.every(num => i % num == 0)) {
        return i;

helps to add a link to the challenge…

I wonder if the reason it fails is because the challenge expects the code to be more efficient…
I had heard that there were such requirements but I’m not sure what they are. Did you try searching the forum to see if this is mentioned?

Tried the suggestion here but it still doesn’t work.

maybe you can try to rewrite to make it more efficient? (for eg. using the greatest common divisor method?)