2021-11-30

My browser lags when I try a loop function?

I wrote a simple nested loop function to multiply all items in an array and output the total value, but each time is I run a loop function my browser either crashes or doesn't stop loading

function multiplyAll(arr){ 
        Let product = 1;
       for(let i = 0; i < 
            arr.length; i++){
            for(let j = 0; j < 
     arr[i].length; j *= product);
     }
      return product;
}

multiplyAll([[1], [2], [3]]);


from Recent Questions - Stack Overflow https://ift.tt/3rkCh1L
https://ift.tt/eA8V8J

No comments:

Post a Comment