Smallest Common Multiple - potential infinite loop on some test cases

Tell us what’s happening:
my function passes all the tests except the last two, which happen to contain much larger integers resulting in larger loops. The error that i’m getting when i run the function with these arguments - [1, 13] or [23, 18] in is that there is a potential infinite loop? Does anyone know why this is happening, and could it be that the test suites cap loops to a maximum iterations before they’ll throw a potential infinite loop warning, even if eventually the function would return and the loop would stop?

Your code so far

function smallestCommons(arr) {
  let sorted = arr.sort((a, b) => a-b)
  let s = sorted[0]
  let b = sorted[1]
  let target = (b-s)+1
  for(let c = b*2; c; c++){
    let count = 0
    for(let i = s; i <= b; i++){
      if(count == target){
        return c


Your browser information:

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

Link to the challenge:

UPDATE: I just disabled the infinite loop protection on and my function returned the target values for the all the tests on FCC.
This leads to a new question of how do i disable infinite loop protection on FCC so i can get credit for passing the challenge?

You can not. You must refactor your solution to use a more efficient algorithm.


so far c+=b*2 passed [1, 13]. just gotta refactor some more

passed! Thanks again!