Hello,

For the Smallest Common Multiple assignment I came up with the following code that is currently working for all testing scenarios. However, I wonder whether this code, that I assume is using Brute-force search algorithmic paradigm by checking every possible option of common multiple for all array entries until it finds one, would be considered as “bad” coding practice? What other algorithms could be used to make the code more efficient?

My code:

```
function smallestCommons(arr) {
let nums = [];
if (arr[1] >= arr[0]) {
for (let i=arr[0]; i <= arr[1]; i++) {
nums.push(i);
}
} else {
for (let i=arr[1]; i <= arr[0]; i++) {
nums.push(i);
}
}
let smallestCommon = 0;
let j=1;
while (smallestCommon == 0) {
let commonMultipleCount = 0;
for (let k=nums[0]; k <= nums[nums.length-1]; k++) {
if (j % k == 0) {
commonMultipleCount++;
}
if (commonMultipleCount == nums.length) {
smallestCommon = j;
break;
}
}
j++;
}
return smallestCommon;
}
```

**Your browser information:**

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

.

**Challenge:** Smallest Common Multiple

**Link to the challenge:**

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