"Smallest Common Multiple" challenge.. i got it right but

Hello! I think that the logic of my code is correct (also the results), but over a certain number i get the error “InternalError: too much recursion”.
Why? arr=[1,12] is still ok, arr=[1,13] crashes…

function smallestCommons(arr) {
  
  
  
  if (arr[1]<arr[0]){   // reverse the array to order the numbers 
       arr.reverse();      //from smallest to bigger
    }
  
  
  
  var remainder;
  var a=arr[0];
  var b=arr[1];   // b will be tested, if it can not be divided by all intermediate             
                  // numbers, will be added himself and tested again
  
  
  
  loop();  
  function loop(){
    remainder=0;
  for (var i=arr[0];i<arr[1];i++){
   
    remainder=b%i;
    
    if(remainder!==0){  
      b+=arr[1];
      loop();
    }  
  }
  }
  
   return b;
  
  
}


smallestCommons([1,12]);

It’s because you call loop() inside itself. When I was first learning Python (an object-oriented language similar to JS), I did lots of recursive function calls, too. Basically, you get a “too much recursion” error because the program is trying to prevent a “stack overflow” (some relation), which is when a single action (in this case, performing loop()'s instructions) takes too much time and/or resources, and potentially crashes the device.

I can’t say how to circumvent this exactly, but it shouldn’t be too hard. for and while loops are your friend when it comes to object-oriented stuff.