# Descending for loop in solution for Smallest Common Multiple challenge

I don’t understand the for loop in the basic code solution for this challenge.

I don’t get what’s going on in `for (var i = arr; i >= arr; i--)` at all (though I understand the push method).

This is the full solution:

``````function smallestCommons(arr) {
// Sort array from greater to lowest
arr.sort(function(a, b) {
return b - a;
});

// Create new array and add all values from greater to smaller from the
// original array.
var newArr = [];
for (var i = arr; i >= arr; i--) {
newArr.push(i);
}

// Variables needed declared outside the loops.
var quot = 0;
var loop = 1;
var n;

// Run code while n is not the same as the array length.
do {
quot = newArr * loop * newArr;
for (n = 2; n < newArr.length; n++) {
if (quot % newArr[n] !== 0) {
break;
}
}

loop++;
} while (n !== newArr.length);

return quot;
}

// test here
smallestCommons([1,5]);
``````

You have a sorted array of 2 items. You start with the first item (arr), and decrement until you hit the second item (arr), pushing every number between arr and arr into the new array.

So, using the example, the loop becomes:

``````for (i = 5; i >= 1; i--) {
newArr.push(i); // (push 5, push 4, push 3, push 2, push 1)
}
``````
1 Like