Smallest Common Multiple Debugging

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)) {
      i = min - 1;
  return target;


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:

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.

1 Like

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

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

1 Like