# Smallest Common Multiple: Can't pass final test case

**URL:** <https://forum.freecodecamp.org/t/smallest-common-multiple-cant-pass-final-test-case/229488>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [September 24, 2018, 4:50pm UTC](https://forum.freecodecamp.org/t/smallest-common-multiple-cant-pass-final-test-case/229488 "2018-09-24T16:50:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stewart-Hetherington](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/stewart-hetherington/32/95482_2.png) [@Stewart-Hetherington](https://forum.freecodecamp.org/u/Stewart-Hetherington)\
**Post date:** [September 24, 2018, 4:50pm UTC](https://forum.freecodecamp.org/t/smallest-common-multiple-cant-pass-final-test-case/229488/1 "2018-09-24T16:50:00Z")

</div>

This code will pass all test cases except for the final test case - [23,18]. Can anyone explain why it isn’t working?

**Your code so far**

```js

function smallestCommons(arr) {
  var max = Math.max(arr[0],arr[1]);
  var min = Math.min(arr[0],arr[1]);
  var current = max;

  for(var i = max; i > min; i--) {
    if(current % i != 0) {
      current += max;
      i = max;
    }
  }
  //console.log(current);
  return current;
}
smallestCommons([18, 23]);

```

**Your browser information:**

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

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/smallest-common-multiple)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![ArielLeslie](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/arielleslie/32/264841_2.png) [@ArielLeslie](https://forum.freecodecamp.org/u/ArielLeslie)\
**Post date:** [September 24, 2018, 4:51pm UTC](https://forum.freecodecamp.org/t/smallest-common-multiple-cant-pass-final-test-case/229488/2 "2018-09-24T16:51:36Z")

</div>

FCC has infinite loop protection to prevent your browser from crashing if you create an infinite loop or infinite recursion. This protection is timer-based, so if your code is inefficient it may trigger the infinite loop protection even if it would eventually terminate. This may be the case with your solution.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [February 2, 2021, 11:29am UTC](https://forum.freecodecamp.org/t/smallest-common-multiple-cant-pass-final-test-case/229488/3 "2021-02-02T11:29:40Z")

</div>

Closed on February 2, 2021, 11:29am UTC


