Error on "Smallest Common Multiple" e

My solution to this problem is this:


function smallestCommons(arr) {
  let start = Math.min(...arr);
  let end = Math.max(...arr);
  let number = end;
  let stop = false;
  console.log("start", start, "end", end, "number", number);

  while(!stop){
    let valid = true;
    for(let i=start; valid && (i <= end); i++){
      valid = (number % i === 0);
    }
    if(valid)
      stop = true;
    else
        number++;
  }
  console.log("Arr", arr, "Number:", number);
  return number;
}

I tried out directly in the browser and it is working correctly but when I run on FCC it fails for [1, 13] and [23,18].

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums