SMC Algorithm Not Succeeding

Hey, i have no idea what I am doing wrong:

Intermediate Algorithm Scripting: Smallest Common Multiple

function smallestCommons(arr) {
function numerically(a, b){
   if(a < b){
      return -1;
   } else if(a > b){
      return 1;
   } else {
      return 0;
   }
}

arr.sort(numerically);
  
const SMC;
let j=arr[1];

  for (let i=arr[0]; i < arr[1]; i++) {
    // Sorted array range loop
    for (; i <= arr[1];) {
        // Loop starting at end of range, trying to find SMC & then return that
        if(i % j !=0 && i == arr[1]) {
          SMC=j;
        }
        else if (Number.isInteger(pass)) {
          continue;
      } else {
        j++;
      }
      return SMC;
    }
  }
}




smallestCommons([1,5]);

Thanks for help!

You have a couple of issues.

  1. You can not declare a variable with const without assigning an initial value to it.

  2. You reference a variable named pass in the following line, but you never declare it in your code.

else if (Number.isInteger(pass)) {

There are a few other issues relating to your inner for loop exit condition, but I will leave that for you to figure out.