Smallest Common Multiple and again almost same

Tell us what’s happening:

I already asked this question, but i’m ask it again with additional clarification:
Function works fine on local computer and executes in 330ms. While previous version of it got executed for ~1.4min on local machine. You can already can see improvement. But FCC says execution took 1241ms?! Does FCC do some background processes or what? Anyhow, i have no further recourse but to use //noprotect. If anyone knows how i can speed up execution from 330ms/FCC’s 1241ms to less time i’ll listen. At this point i have no new ideas … Here’s a pen: and in codepen execution time is >130ms which is peak not average time of execution. Edit1: Because it thinks it’s endless loop, it exits loop earlier so result is far lower then it should be.

Your code so far

function smallestCommons(arr) {

arr.sort();
var arr1=[];

	for(var i=arr[0];i<=arr[1];i++){
	
		arr1.push(i);
	
	}

	var x=1;

	function check(arr1) {

		if (x%arr1==0){
			return x%arr1==0;
		}
	}

	while(x){
	
		x++;
		
		if(arr1.every(check)==true){

			break;
		}
	 
	}
  return x;
}

smallestCommons([1,5]);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/smallest-common-multiple

A post was merged into an existing topic: Smallest Common Multiple acting weird? Or just browser?