# Smallest Common Multiple-Am I on the right track? Thanks!

This is my code so far:

When I console.log at line 8, I get [1,5], the expected result. However, when I console.log after line 14, I get null. Might anyone know why this is? Thanks!

I’ve changed my code. Trying to wrap my head around this problem. Also, wondering if I’m taking the right approach.

``````
function smallestCommons(arr) {

//sort array of numbers.
arr.sort(function(a, b){
return b-a;
});

//create new array
var newArr = [];
//array should contain two numbers and all numbers in between from greatest to lowest
for(var i = arr[1]; i < arr[0]; i++) {
newArr.push(i);
}

//take largest number, assign it to var lcm (lowest common multiple), divide other numbers into it. If all remainders are zero, break.
var lcm = arr[0];
for(var j = 1; j < newArr.length; j++) {
if (lcm % arr[j] == 0) {
return lcm;
} else {
lcm *= 2;
}
}
//multiply largest number by two and divide other numbers into it again. If all remainders are zero, break.

//return arr;

}

smallestCommons([1,5]);
``````

Should I use the .every method?