I can't get that lesson

Tell us what’s happening:

I can’t understand the lesson…

Your code so far


function multiplyAll(arr) {
var product = 1;
// Only change code below this line

// Only change code above this line
return product;
}

multiplyAll([[1,2],[3,4],[5,6,7]]);

Your browser information:

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

Challenge: Nesting For Loops

Link to the challenge:

What is it exactly that you are having trouble understanding with?

i can’t understand what i++ does, and than is used as arr[i].length

Or i don’t know what for does

How did you pass the challenge before this one if you do not know what i++ does?


arr[i].length is the length of the nested array currently being iterated over.

const numbers = [[5, 6, 7], [2, 8]];

console.log(numbers[0].length); // 3
console.log(numbers[1].length); // 2

The example code given in the challenge pretty much takes you 85% through the challenge.

for (var i=0; i < arr.length; i++) {
  for (var j=0; j < arr[i].length; j++) {
    console.log(arr[i][j]);
  }
}

Now instead of logging the array elements console.log(arr[i][j]) you need to multiply the element value with product and assign the result back to product.

let number = 50;

number *= 2;
console.log(number); // 100

number *= 2;
console.log(number); // 200