Smallest Common Multiple --- Modulo

Hello everyone! I’m new here.
The if statement doesn’t seem to execute at all with the given condition.

function smallestCommons(arr) {
  
  var max = arr[0] < arr[1] ? arr[1] : arr[0];
  var min = arr[0] > arr[1] ? arr[1] : arr[0];
  var top = max;
  var bool = true;
  
  while(bool === true){    
    for(var j = min, k = 1, count = 0; j < max; j++, k++){
      if(top % max-k === 0){
        count++;
      }
    }
    if(count != k)
      top += max;
    
    else
      bool = false;
  }  
  return top;
}

smallestCommons([1,5]);

Its working now :smile:

if(top % (max-k) === 0)

but still have’t solved the entire problem as yet

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

Oh thank you for sharing :joy: