Smallest Common Multiple Debugging

Smallest Common Multiple Debugging
0

#1

Tell us what’s happening:
I have checked my code on browser console and it worked as intended but I cannot pass the test.
Any ideas?

Your code so far


function smallestCommons(arr) {
  let max = Math.max(...arr);
  let min = Math.min(...arr);
  let target = max;
  for (let i = min; i <= max; i++) {
    if (Math.floor(target / i) !== Math.ceil(target / i)) {
      target++;
      i = min - 1;
    }
  }
  return target;
}


smallestCommons([1,5]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) 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

if you search the forum you will find others who have hit the same issue as you. Basically you are failing to pass the last test due to it taking too long to execute and that triggers a forever loop protection in FCC.
There are ideas on how to workaround this on the forum or how to rewrite the code to work faster on the forum.


#3

So I almost pass the test? This is my best solution though XD
Guess I have to rewrite my code to work faster.


#4

yes finding a quicker processing time is part of the challenge here.