Find the Least Common Multiple

Tell us what’s happening:
So I have tried to create this ‘multiple’ function which calls itself using the every() method to check until the number is a multiple of all given numbers. I have kinda confused myself in the process, I feel very close yet also feel so far. I don’t know if my train of thought is correct. Any pointers will be of great help. thank you.

  **Your code so far**

function smallestCommons(arr) {
  const arr1 = arr.sort((a,b)=>a-b)
const [a,b] = arr1;
let lcm = 0;

const multiple = (a,b,lcm)=>{    
  let i=a;    
    if(i==1){lcm += b; i++;};
    if(i > 1 && lcm%i != 0){                
      lcm += b;     
  let arr2 = []
  for(let j=a; j<b+1; j++){
  const isMultiple = (i) => lcm % i == 0;
  if((arr2.every(isMultiple)) == false){
    return lcm

//return arr;

  **Your browser information:**

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

Challenge: Smallest Common Multiple

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.