# Smallest Common Multiple Working But Not Passing

Hi!

I found a solution to the smallest common multiple challenge, but the grader says that none of the tests are passing. What am I doing wrong??

``````function gcd(arg1, arg2) {
var div = 1;

while (div > 0) {
div = arg1 % arg2;
if (div === 0) {
return (arg2);
} else {
arg1 = arg2;
arg2 = div;
}

}
return (1);
}

function leastCommon(arg1, arg2) {
var larger;
var smaller;
var divisor;

// Check if either argument is equal to 1
if (arg1 === 1) {
return arg2;
} else if (arg2 == 1) {
return arg1;
}

// Make larger the larger of the two arguments
if (arg1 > arg2) {
larger = arg1;
smaller = arg2;
} else {
larger = arg2;
smaller = arg1;
}

// Get the greatest common divisor
divisor = gcd(larger, smaller);
return ((larger * smaller) / divisor);

}

function smallestCommon(arr) {

var result;
var numbers = [];
var max;
var min;

// Set up the initial numbers array
if (arr[0] > arr[1]) {
max = arr[0];
min = arr[1];
} else {
max = arr[1];
min = arr[0];
}

for (var j = min; j <= max; j++) {
numbers.push(j);
}

// Main Logic
result = leastCommon(numbers[0], numbers[1]);
for (var i = 2; i < numbers.length; ++i) {
result = leastCommon(result, numbers[i]);
}
return (result);
}

console.log(smallestCommon([1, 5]));
console.log(smallestCommon([5, 1]));
console.log(smallestCommon([1, 13]));
console.log(smallestCommon([23, 18]));
``````

I tried your solution and all the tests pass. Try refreshing the page and running the tests again.