Smallest Common Multiple | Wrong validation to running code

Tell us what’s happening:

I think the platform is evaluating my code erroneously, because my solution match all requirements but the console says:

smallestCommons([23, 18]) should return 6056820

even if the tests is passing.

Your code so far

function smallestCommons(arr) {
  let scm = 1
  const orderedArr = arr.sort((a, b) => a > b)
  const [ min, max ] = [ Math.min(...orderedArr), Math.max(...orderedArr) ]
  const quotients = [...Array(max + 1).keys()].slice(min, max + 1)
  while(true) {
    const isDivisible = quotients.every(q => scm % q === 0)
    if (isDivisible) return scm

smallestCommons([23, 18])

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0.

Link to the challenge:

I think you are probably right, because on the new public beta platform (notice: .dev TLD) your code passes all tests:

1 Like

The issue is your code is not efficient enough for all the tests to complete, so the FCC infinite loop protection FCC stops the code from running completely. Change your algorithm to something more efficient and you will pass the current production tests.

1 Like