Smallest Common Multiple debugger false-positive

Smallest Common Multiple debugger false-positive
0

#1

The debugger returns the following errors:

smallestCommons([1, 13]) should return 360360.
smallestCommons([23, 18]) should return 6056820.

The thing is smallestCommons([1, 13]) & smallestCommons([23, 18]) are returning 360360 and 6056820 respectively.

Any idea what should I do?

My code so far


function smallestCommons(arr) {
  arr = arr.sort((x,y) => x-y);
  let val = arr[0]+1;
  let index = arr[1];
  let mul = 2;
for(let i=1; i<index-arr[0]; i++)
{
	arr.splice(i, 0, val);
	val++;
}

for(let i=0; i<arr.length; i++)
{
	if(mul%arr[i]===0)
	{
		continue;
	}
	else
	{
		mul++;
		i=-1;
	}
}
return mul;
}

smallestCommons([1,5]);

Your browser information:

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

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