Smallest Common Multiple - code seems correct but past two tests are failing?

Smallest Common Multiple - code seems correct but past two tests are failing?
0

#1

Tell us what’s happening:
When I run my code in VS I get the right answers but when I run in the FCC console it says the last two tests aren’t correct even though I’m getting the right answer for them in my code editor.

If anybody has encountered similar problem or they notice a mistake I’ve overlooked I’d love to hear your feedback!

Thanks,
Andy!
Your code so far


function smallestCommons(arr) {
  let nums = [];
  let limit = Math.pow(10, 1000);
//Create an array of values between the range of the two numbers given
  if(arr[0] > arr[1]) arr.reverse();
  for(let i=arr[0]; i<= arr[1]; i++) {
    nums.push(i);
  }
//Create an array begin at the first number in the array and carrying on to infinity 
  for (let i=arr[0]; i<=limit; i++) {
    let counter = [];
    let checker = i;
//Nest a loop that will loop over the values in the range array checking if each value is a multiple of the checker value
    for(let j=0; j<=nums.length; j++) {
      if(checker%nums[j] === 0) {
//If one of the number in the range array is a multiple of the checker value push it into the counter array
          counter.push(checker);
      }
//If the lengths of the counter array matches the length of the range array then print the checker value
      if(counter.length === nums.length) {
          console.log(checker);
          return checker;
      }
    }
  }
}

smallestCommons([1, 13])
smallestCommons([1,5]);

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


#2

Have you tried searching the forum for the problem you are experiencing? I bet you there is at least one person who has had this same issue before.


#3

I’ve typed the name of the challenge into the search bar but unfortunately it seems only two others had issues with this challenge, neither of which seem relevant to my problem. I’m new to using the forum, so it is possible that I am not searching in the correct areas.