**Tell us what’s happening:**

Hey guys, my script can’t pass only the last test. Actually, the console calculations stop in a specific number. Any help would be greatly appreciated. Thanks!

**Your code so far**

```
function smallestCommons(arr) {
let firstEl = arr[0];
let lastEl = arr[arr.length - 1 ];
let min = 0;
let max = 0;
let newArr = [];
let count = 0;
let lastScm = 0;
if(firstEl < lastEl ){
min = firstEl;
max = lastEl;
}
else{
min = lastEl;
max = firstEl;
}
let divNum = max;
for( let i = min; i <= max; i++ ){
count++;
newArr.push(i);
}
function divCm(divNum){
let sum = 0;
for(let i = min; i <= max; i++){
if(divNum % i == 0){
sum += 1;
}
}
return sum;
}
function getScm(divNum){
let j = 2;
while(lastScm !== count){
lastScm = divCm(divNum);
if(lastScm === count){
return divNum;
}
divNum = max*j;
j++;
}
}
let endScm = getScm(divNum);
console.log(endScm)
return endScm;
}
smallestCommons([23,18]);
```

**Your browser information:**

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

.

**Link to the challenge:**

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