**Tell us what’s happening:**

I can’t understand whats wrong with my code. It gives correct answers till number “12” and goes haywire after that.

**Your code so far**

```
console.clear();
function smallestCommons(arr) {
arr.sort((a,b)=>(a-b));
let answer = 1;
let flag = 1;
while(flag==1){
flag = 0;
answer++;
for (let j = arr[0]; j <= arr[1]; j++){
if (answer % j !== 0){
flag = 1;
}
}
}
return answer;
}
console.log(smallestCommons([1,12])); //27720 : correct
console.log(smallestCommons([1,13])); //logs different numbers every time
```

**Your browser information:**

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

.

**Link to the challenge:**

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