Nesting For Loops(0)

Tell us what’s happening:
I’m trying to solve a problem where you multiply all elements of a 2 dimensional array together using nested for loops. The code I have written so far won’t correctly compute the product, though it appears to me that it should. What is wrong with the code I have written?

Your code so far

function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for(var i = 0; i < arr.length-1; i++)
    {
      for(var j = 0; j < arr[i].length-1; j++)
        {
          product *= arr[i][j];
        }
    }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Your browser information:

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

Link to the challenge:
https://www.freecodecamp.org/challenges/nesting-for-loops

You have off-by-one errors. Your loop conditions should not subtract 1 from the length, or the last numbers won’t be multiplied.