Tell us what’s happening:
Hello ,
There’s something strange when I run the tests with my code. Every test works but something goes wrong with [23,18] ??
It works on my browser with my Bracket’s code but not with the freeCodeCamp’s tests…
I’d be very thankful for your help !!!
Your code so far
function smallestCommons(arr) {
let arrRange = [];
let temp = 1;
let result;
let arrTemp = [];
if(arr[0]>arr[1]){
arrTemp[0] = arr[1];
arrTemp[1] = arr[0];
} else {arrTemp = arr}
console.log(arrTemp);
let n= arrTemp[0];
while(n <= arrTemp[1]){
arrRange.push(n);
temp *= n;
n++;
}
for(let i=1; i<=temp; i++){
function test(nbr){
return i%nbr==0;
}
if(arrRange.every(test)){
result = i;
break;
}
}
console.log(result);
return result;
}
smallestCommons([23,18]);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/smallest-common-multiple