Smallest Common Multiple: Brute-force solution?

Smallest Common Multiple: Brute-force solution?


Tell us what’s happening:

Hey guys, using a brute force solution here but not passing the last test. It appears that the number returned is different every time whenever I run it on JSbin. Does anyone know why?

Your code so far

function smallestCommons(arr) {
  const MIN = Math.min(...arr);
  const MAX = Math.max(...arr);
  let isFound = false;
  let currNumber = 0;
  while(!isFound) {
    currNumber += MAX;

    for(let i=MAX; i>= MIN; i--) {
      if(currNumber % i !== 0) {
      else if(i===MIN) {
        isFound = true;

  console.log(MIN + " " + MAX + " " + currNumber);
  return currNumber;


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:


yup, you’re hitting the FCC timeout

If you search the forum you can find others who did the same and suggestions on workarounds and code-rewrites you can do.