Smallest Common Multiple - why doesn't this work?

Can anyone tell me what’s wrong with my logic?

Your code so far


function smallestCommons(arr) {
// variables
let sortedArray = arr.sort( (a, b) => a - b); // sort the array into numerical order
let fullNumericalArray = [];
let gap = sortedArray[1] - sortedArray[0] - 1;
let multiple = sortedArray[0] * sortedArray[1];

// function to fill an array with sequential numbers
function fillArray() {

  for (let i = 0; i < gap; i++) {
  fullNumericalArray.push(sortedArray[0]+ (i+1));
  }
  
fullNumericalArray.push(sortedArray[1]);
fullNumericalArray.unshift(sortedArray[0]);
}

// function to find smallest common multiple
function findMultiple() {
  
  let arrayIndex = 0
  let target = fullNumericalArray.length

  while (arrayIndex !== target) {

    // if false, increment test multiple by 1, set array index to 0
    if((multiple % fullNumericalArray[arrayIndex]) == 0) {
      
      //work out next multiple and assign to variable
      let i = multiple + 1;
      
      while(i % sortedArray[0] == 0 && i % sortedArray[1] == 0) {
        i += 1;
      }

      multiple = i;
      arrayIndex = 0;
      continue
    }

      // if true, keep test multiple, increment aray index by 1
    if((multiple % fullNumericalArray[arrayIndex]) == 0) {
      arrayIndex += 1;
      continue
    }  
  }
}

// call functions

fillArray();
findMultiple()
console.log(multiple)
return multiple;
}


smallestCommons([1,5]);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

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

your while loop may have some issues. I have difficulties understaind what it is doing, could you please guide me step by step in your logic? I mean mathematically

While loops are notorious for causing infinite loops.
You didn’t say what steps you took so can I recommend you look at the hints:
https://guide.freecodecamp.org/certifications/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/smallest-common-multiple/