Smallest Common Multiple problem with tests... or with my code

Tell us what’s happening:
Hello :slightly_smiling_face: ,
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… :face_with_raised_eyebrow:
I’d be very thankful for your help !!! :yum:

Your code so far

function smallestCommons(arr) {
    let arrRange = [];
    let temp = 1;
    let result;
    let arrTemp = [];
        arrTemp[0] = arr[1];
        arrTemp[1] = arr[0];
    } else {arrTemp = arr}
    let n= arrTemp[0];
    while(n <= arrTemp[1]){
        temp *= n;
    for(let i=1; i<=temp; i++){
        function test(nbr){
            return i%nbr==0;
            result = i;
    return result;


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:

Hey @lebowvsky,
Your code needs to be efficient to pass the challenge.
Your code is activating the FCC’s infinite loop protection.

So, try to make your code a little efficient.

All the best.

Thank you @aditya_p,
I understand that my loop is recognized as an infinite loop by FCC’s protection, that’s why it works on brackets but not on FCC.
Ok! I’ll try to find something better! :sweat_smile:
Thank you very much for your help !!! :grinning: :+1:

1 Like