Smallest Common Multiple, can't pass the last two tests

Tell us what’s happening:

I’m not passing the last two tests. I don’t know if it has something to do with larger values.

Your code so far

function smallestCommons(arr) {
  var small = Math.min(...arr);
  var large = Math.max(...arr);
  var array = [];
  for(var i = small; i <= large; i++) {

  var x = true;
  var LCM = 0;
  while(x) {
    for(var j = array[0]; j <= array[array.length - 1]; j++) {
      if(LCM % j !== 0) {
      else if(j == array[array.length - 1]) {
        x = false;
  return LCM;


Your browser information:

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

Link to the challenge:

Your code appears to give the correct output for the failing tests - I’m not sure on this, but there may be something behind the scenes that stops your code from running through the tests if there’s too many calculations involved or something - for preventing infinite loops, and crashing your browser. Your code doesn’t have an infinite loop, but there’s probably a lot of calculations in those last two tests that may be triggering the testing to be stopped. Don’t quote me on this, I’m trying to find a post or something to confirm…
this post explains the problem, and gives a solution - however, I don’t think that solution works at the moment on the new website - I don’t know of any other quick solutions, you could try and make your algorithm faster to finish the tests within the time limit

Usually when you fail the test for the large numbers but it works elsewhere (like it does in codepen) that means that it is timing out before you can get the answer. The testing has a built in time limit. This means that you have to make your code more efficient. This is a common issue in programming. Try to find ways to maker your algorithm more efficient.