**Tell us what’s happening:**

my code is logically sound, but I suppose making my code loop 6 million times is a little too much xD

So I don’t know what to do anymore, I’ve been doing this for hours and finally got it right but it was “too much” load and so FCC isn’t accepting it (and I kind of agree) basically here’s how it should be

I need to return a range from the given array

if 5, 1 then 5 4 3 2 1 or 1 2 3 4 5

then find the least common multiple which in 5, 1 is 60 since 60 is the lowest number divisible byall 1 2 3 4 5 without remainders

My approach

my approach was basically increment a variable until all of it is divisible by all the numbers in an array. and my computer didn’t find it fun and was having trouble looping through something 6 million times.

so now, how do I redo this thing? xD I’m totally lost.

**Your code so far**

```
function smallestCommons(arr) {
let newArr = [...arr]
newArr.sort(function(a, b) {
return b -a;
});
let range = [];
for (let i = newArr[0]; i >= newArr[1]; i--){
range.push(i);
}
console.log(range + " after first for loop");
let flag = true;
let x = 0;
while (flag){
x++
for (let i = 0; i < range.length; i++){
if (x % range[i] != 0){
break;
} else if (i == [range.length -1]){
flag = false;
}
}
}
return x;
}
smallestCommons([2, 10]);
/*
sort your array
create your range
*/
```

**Your browser information:**

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

.

**Link to the challenge:**

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/smallest-common-multiple/