Smallest Common Multiple Not Working With All Test Cases

Tell us what’s happening:

I’m currently doing the smallest common multiple intermediate algorithm challenge. For some reason, my code works with three of the four test cases, but the last one it doesn’t work with. My code outputs the correct number, but the thing on FCC doesn’t accept it as a valid solution. Could someone please just paste my code in an see if it works for them, or if there’s just something wrong with my computer?

Your code so far

  var isItReally = false;
  var isItSmallest = 0;
  var arrToTest = [];
  if(arr[0] > arr[1]){
    arr[2] = arr[1];
    arr[1] = arr[0];
    arr[0] = arr[2];
    arr.splice(2,1);
  }
  for(i=arr[0]; i<=arr[1]; i++){
    arrToTest.push(i);
  }
  var counter = (arrToTest[(arrToTest.length-1)] * 2);
  while(isItReally == false){
    isItSmallest = 0;
    for(i=0; i<arrToTest.length; i++){
      if(counter % arrToTest[i] == 0){
        isItSmallest++;
      }
    }
    if(isItSmallest == (arrToTest.length)){
      isItReally = true;
    } else{
      isItReally = false;
      counter++;
    }
  }
  return counter;
}

smallestCommons([1,5]);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/smallest-common-multiple

Your code is taking long enough to run on the last two tests that it is setting off FCC’s infinite loop protection.

Ah. That makes sense. Thank you!