# Smallest Common Multiple - I can't make the last test work :(

**URL:** <https://forum.freecodecamp.org/t/smallest-common-multiple-i-cant-make-the-last-test-work/146295>\
**Category:** General\
**Created:** [September 6, 2017, 10:43am UTC](https://forum.freecodecamp.org/t/smallest-common-multiple-i-cant-make-the-last-test-work/146295 "2017-09-06T10:43:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mathilde206](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/mathilde206/32/161371_2.png) [@mathilde206](https://forum.freecodecamp.org/u/mathilde206)\
**Post date:** [September 6, 2017, 10:43am UTC](https://forum.freecodecamp.org/t/smallest-common-multiple-i-cant-make-the-last-test-work/146295/1 "2017-09-06T10:43:02Z")

</div>

**Tell us what’s happening:**  
Hi everyone  
I’m really going crazy with this smallest multiplier challenge. I’m almost there, it’s now working for all tests except the last one : smallestCommons([23,18]). Does someone have an idea why and where the problem is with my code ?

**Your code so far**

```auto
function smallestCommons(arr) {
  var max = Math.max(arr[0], arr[1]);
  var min = Math.min(arr[0], arr[1]);
  var fullArray = [];
  
  for(var i=max; i>=min; i--){
   fullArray.push(i);
  }
 
  var i = 0;
  var SCM = fullArray[0];
  var multiplied = 1;
  
  do{
    multiplied = SCM * fullArray[0];
    
    for(i=1; i<fullArray.length; i++){
      if(multiplied % fullArray[i] !== 0){
        SCM += fullArray[0];
        break;
      }
    }
  }
  while(i<fullArray.length-1);
  
  return SCM;
  
}
smallestCommons([23,18]);

```

**Your browser information:**

Your Browser User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36`.

**Link to the challenge:**  
[https://www.freecodecamp.org/challenges/smallest-common-multiple](https://www.freecodecamp.org/challenges/smallest-common-multiple)

---

<div class="post-metadata">

**Author:** ![v-lai](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/v-lai/32/65024_2.png) [@v-lai](https://forum.freecodecamp.org/u/v-lai)\
**Post date:** [September 7, 2017, 5:12am UTC](https://forum.freecodecamp.org/t/smallest-common-multiple-i-cant-make-the-last-test-work/146295/2 "2017-09-07T05:12:50Z")

</div>

You are super close to a working solution to pass the tests! 😃

Double check your while loop condition.

---

<div class="post-metadata">

**Author:** ![mathilde206](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/mathilde206/32/161371_2.png) [@mathilde206](https://forum.freecodecamp.org/u/mathilde206)\
**Post date:** [September 7, 2017, 9:43am UTC](https://forum.freecodecamp.org/t/smallest-common-multiple-i-cant-make-the-last-test-work/146295/3 "2017-09-07T09:43:44Z")

</div>

wow thank you, I feel really stupid now 🙈 I spent so much time on this, I didn’t even see the obvious !!

---

<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:** [January 17, 2021, 8:40pm UTC](https://forum.freecodecamp.org/t/smallest-common-multiple-i-cant-make-the-last-test-work/146295/4 "2021-01-17T20:40:17Z")

</div>

Closed on January 17, 2021, 8:40pm UTC


