Nesting For Loops - Returning Null

Nesting For Loops - Returning Null
0.0 0

#1

Ok,

For the Nesting For Loops task I keep getting the result “null”.

I’ve tried deleting the 3rd nested loop (k) and have moved around the return statement.

I’ve commented out all of my code so that someone can see my intentions in plain English.

What have I done wrong?

Thanks!

  function multiplyAll(arr) {
    //This is a variable named "product" with it's value initialized to 1. 
  var product = 1;
  
  // Only change code below this line
    //This is the beginning of a for loop that says "start at 0, the first "block" of values in an array, and given that the variable is containe within the length of the array, evaluate and go to the next variable (++ or +1) each time. 
  for (var i=0; i < arr.length; i++){
    //This is a nested for loop that says "start at position 1, the second "block" of values in an array, and given that the variables contained within the length of the 2nd array of arrays, evaluate and go to the next variable  - repeat.  
    for (var j=1; j < arr[i].length; j++){
      for (var k=2; k < arr[j].lenth; k++){
  }
      //This should return the variable, product (equal to 1) times each value in each of the arrays. 
      return product *= arr[i][j][k];
        }
  }
  // Only change code above this line
  
}

// Modify values below to test your code
multiplyAll([[5,1],[0.2,4,0.5],[3,9]]);


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

#2

Why are you starting j at 1?


#3

So that the loop starts at position 1, the second “block” of values in an array,


#4

Why are you skipping the first item of each nested array?


#5

it should be i=0 for all loops. You are not looping 2 or third array.