Challenge: Smallest Common Multiple works but only for small numbers

**I’m currently working on the challenge: Smallest Common Multiple
The smallest common multiple between two numbers is the smallest number that both numbers can divide into.

When I run the tests, my code works for all of the arrays except for the last one:

smallestCommons([23, 18])

The way my program works: It’s just a while loop checking over and over again if the current number is the Least Common Multiple of the Arrray. If not, it increases the num by one and tries again. This loops until the correct number is found. I’m pretty sure there is a far more efficient way to do this. Can yo help me out? My guess is: When the numbers to test get too big, the program crashes, see console message:

"Potential infinite loop detected on line 39. Tests may fail if this is not changed."

function smallestCommons(arr) {

  function getmin(arr) {
    return Math.min.apply(Math, arr);

  function getmax(arr) {
    return Math.max.apply(Math, arr);

  function divisor(arr) {
    // returns the range (for ex. [1,2,3,4,5] for the Array [1,5]
    var max = getmax(arr);
    var min = getmin(arr);
    var a = [];
    for (var i = 0; i < (max - min + 1); i++) {
      a.push(getmin(arr) + i)
    return a;
  const div = divisor(arr); // for ex. [1,2,3,4,5]

  function checkIFWORKS(n, arra) {
    //this is the crucial part of the program

    for (var i = 0; i < div.length; i++) {

      if (n % div[i] !== 0) {
        return false; // check if each numer has to be dividable without remainder
    return true;

  var num = getmax(arr);
  while (checkIFWORKS(num, arr) == false) {
    num = num + 1;
    //try it with brute force.
    //increase the number everytime by 1 and check if it can divide witout remainder 
  return num;
console.log(smallestCommons([23, 18]));

Your browser information:

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

Challenge: Smallest Common Multiple

Link to the challenge: