Smallest Common Multiple: Can't pass final test case

Smallest Common Multiple: Can't pass final test case
0

#1

This code will pass all test cases except for the final test case - [23,18]. Can anyone explain why it isn’t working?

Your code so far


function smallestCommons(arr) {
  var max = Math.max(arr[0],arr[1]);
  var min = Math.min(arr[0],arr[1]);
  var current = max;

  for(var i = max; i > min; i--) {
    if(current % i != 0) {
      current += max;
      i = max;
    }
  }
  //console.log(current);
  return current;
}
smallestCommons([18, 23]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

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


#2

FCC has infinite loop protection to prevent your browser from crashing if you create an infinite loop or infinite recursion. This protection is timer-based, so if your code is inefficient it may trigger the infinite loop protection even if it would eventually terminate. This may be the case with your solution.


Smallest Common Multiple assertion issue