Smallest Common Multiple not working [help]

Tell us what’s happening:
Hello, i’m trying to achieve the Smallest Common Multiple challenge. I found a way to find the Smallest common multiple of two numbers, but i don’t know how to do this with a range. Someone can help me ? Thank’s.

Your code so far

function smallestCommons(arr) {

  // division parts
  let dividend  = Math.max(arr[0],arr[1]);
  let divisor   = Math.min(arr[0],arr[1]);
  let between   = [];
  let quotient  = Math.floor(dividend/divisor);
  let remainder = dividend % divisor;

  // sCM = smallest common multiple
  let sCM = 0;

  // gCD = greatest common divisor
  let gCD = 0;

  // this function returns Greather Common Divisor of two numbers
  function GCD(dividend,divisor){

    while (remainder != 0){
      dividend  = divisor;
      divisor   = remainder;
      remainder = dividend % divisor;

    return divisor

  // this function returns numbers between the min and max range
  for ( let i = dividend; i >= divisor; i--){

  gCD = GCD(dividend,divisor)
  sCM = (dividend * divisor)/gCD


  // is not defined yet
  return result



Your browser information:

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

Link to the challenge:

So you go through each number in ‘between’ and see if it is a factor of ‘sCM’, if any fail, iterate through multiples of ‘sCM’ and go through each number in ‘between’ again. Keep looping through till some multiple of ‘sCM’ is also a multiple of each number in ‘between’.

hint, given your input numbers I expect it to not be small. :slight_smile: