Smallest multi challenge

Tell us what’s happening:
Describe your issue in detail here.
I tried to solve this challenge using my own head but ended up explode my mind.
Can someone help me spot my mistake

  **Your code so far**

function smallestCommons(arr) {
arr = arr.sort((a,b) => a-b);
let [small,large] = [...arr];
let newArr = [];
var result;
for (let i = small; i <= large; i++) {
  newArr.push(i)
}
function check(num) {
  for (let j = 0; j < newArr.length; j++) {
    if (num % newArr[j] !== 0) {
      return false;
    }
  }
  return num
}
function multi (num,low) {
  num *= low
  result = check(num)
  if (result == false) {
    result = multi(num,low+1)
  }
  else {
    return result
  }
}
let answer = multi(large,small)

return answer;
}

console.log(smallestCommons([5,1]));

  **Your browser information:**

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

Challenge: Smallest Common Multiple

Link to the challenge:

I don’t think this does what you think. I wouldn’t use recursion in this way for this challenge. Can you describe how you think this logic works? There is a simple looping approach that works much better here.

1 Like

wow this confuse me…honestly

oops, I really have no idea where am I lacking.
So the code that I write is actually just my guess and that is why I ended up like this.
As soon as I view the solution, then only I can imagine how to actually write it properly.
there is still a lot of time i need to spend to learn probably.
Truly sorry for my dumb code :sweat_smile:

HAHAHAHAH, even myself confused

You don’t need to apologize for your code. And you didn’t need to look up the answer.s. If you had talked to us, we could have worked on fixing the code together.