Smalles Common Multiple help

Smalles Common Multiple help
0

#1
function smallestCommons(arr) {
  var numbers = arr.sort();
  var array = [];
  for(var i = numbers[0]; i <= numbers[numbers.length - 1]; i++){    
      array.push(i);    
  }
  var x=true;
  var count=0;
  while(x){
    count++;
    for(var j=array[0]; j<=array[array.length - 1]; j++){
      if(count % j !== 0){
        break;
      }
      else if(j == array[array.length - 1]){
        x = false;
      }
    }
  }
return count; 
}
smallestCommons([1,5]);

works for the first four parameters, but fails on
smallestCommons([23, 18])


#2

I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.