My code doesn't pass test on FCC

Hello,everyone!
Will you please help me to understand why my code doesn’t pass the test for value[1,13] and [23,18] on Free Code Camp? This code works fine on my browser and giving me correct answer.

here is my code…

function smallestCommons(arr) {
  
  let max=Math.max(...arr); 
  
  let min=Math.min(...arr); 
  
  let val=max;
  
  let result;
  
  while(true){ 						 
  
	let b=[];
	
	for (var i=min;i<=max;i++){       
		
		if(val%i===0){
			b.push('true');
		}	
		else{
			b.push('false');
		}
	}		
	if (b.indexOf('false')===-1){
        result=val;
		break;
	}
	else{
		val=val+1;
		continue;
	}
  }
  return result;
}

console.log(smallestCommons([23,25]));

thanks in advance.

If your code passes for other tests, I am sure it has no flaws algorithm wise.

But this challenge will also check for performance. If your code is not optimized, it will take too long. Try looking up similar topics in the forum, this exercise has been asked many times.

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