Tell us what’s happening:

For the last test case its giving potential loop warning in FCC editor, but when I do it browser console with the same code it gives me correct answer.

Your code so far

function smallestCommons(arr) {
var firstNumber,secondNumber;
  firstNumber = arr[1];
  secondNumber = arr[0];
else {
  firstNumber = arr[0];
  secondNumber = arr[1];

var commonMultipleFound = false;
var commonMultiple = secondNumber;

  var count = 0;
  for(var i=firstNumber; i<=secondNumber ; i++){
    if(commonMultiple % i == 0)
  if(count == (secondNumber - firstNumber + 1))
    commonMultipleFound = true;

return commonMultiple;

smallestCommons([23, 18]);

Your browser information:

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

Challenge: Smallest Common Multiple

Link to the challenge:

Mhh, well, … the browser just executes what you feed it, but this test actually gives you a hint for better architecture …

1 Like

Yes , Thanks . Trying to figure that out. :slight_smile:

Sorry, I think my comment wasn’t all that helpful. I would like to add that there is a common multiple you can calculate with certainty. Beyond that it makes no sense to keep searching …

1 Like