Problem 5: Smallest multiple , not working for 13 and 20 on platform but works when run locally

Tell us what’s happening:

This code is working for all test until 13… When I run this code under visual code, it returns the right value for each test case … Is there a mistake in my code ? or is it something with the platform ?

Thank you for your help.

Your code so far


function smallestMult(n) {
  
  let returnVal = 0
  let shouldContinu = true
  let currentIndex = 1

  while(shouldContinu){
    currentIndex++
    if( canBeDividedByAll(1, n, currentIndex) ) {
      shouldContinu = false
      returnVal = currentIndex
    }
  }
  console.log('final value to return '+returnVal)
  return returnVal
}

function canBeDividedByAll( start, end , numberToCheck){
  let returnVal = true


  for(let i = start; i <= end; i++){
    if(numberToCheck % i !== 0) {
      returnVal = false
      break
    }
  }
  //console.log('>> checking number: '+ numberToCheck + ' and return : '+ returnVal)
  return returnVal
}

smallestMult(13);

Your browser information:

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

The FreeCodeCamp has an infinite loop protection to avoid your browser freezing that stop your code if it is taking too much to execute, t seems you code is taking too much time to execute and triggering that one

Thank you for this information , I didn’t know. :wink:
But it seems a bit strange because when I run the code locally , I get this output:

[Running] node "smallest-multiple.js"
>> found all match for: 360360
final value to return 360360
[Done] exited with code=0 in 0.09 seconds

The script takes 0.09 seconds to get the answer … I doesn’t seem very long to me…

The time of execution is different on browser, but to see if that is the issue try to console log the function call of the test you are not passing in the fcc editor and see what result you get