Hallo everybody,
consider the following code:
function solutionReturn(array){
let start;
let otherstart;
while (array.length>1){
start=array[0];
otherstart = array[1];
while (start > otherstart){
otherstart = array[1] + otherstart;
}
//console.log(array);
while (start < otherstart){
start = array[0] + start;
while (start > otherstart){
otherstart = array[1] + otherstart;
//console.log("array[0]:array 1: "+array[0]+" "+array[1]);
}
}
array = array.slice(1);
array[0] = start;
}
console.log('Rückgabewert: '+start);
return start;
}
function smallestCommons(arr) {
let grnum,smnum;
if (arr[0]>arr[1]){
grnum=arr[0];
smnum=arr[1];
}else{
grnum=arr[1];
smnum=arr[0];
}
let divarr=[];
for (let i = smnum; i<=grnum; i++){
divarr.push(i);
}
//console.log('divarr '+divarr)
return solutionReturn(divarr);
}
smallestCommons([1,5]);
Usually I work on Firefox 65.0.1 64 Bit on Arch Linux, and there this code won’t work. The last test would stop somewhere around the result of 4 Mio and claim that was the actual result, which is obviously wrong.
I now tried the same code on Chromium 72.0.3626.109 and suddenly the result is correct and the challenge is solved.
Does anybody of you have an idea, what’s happening? Does Firefox restrict how much you can loop or is there another problem?