I don't get what I am doing wrong: Nesting For Loops

Tell us what’s happening:

Having problems with this code

Your code so far

function multiplyAll(arr) { //here the numbers are brought in
var product = 1; //this set the product variable to 1
// Only change code below this line

for(var i =0; i <arr.lenght; i*1){ //basicly adds the numbers we need to go trough until the lengt of the array is reached but instead of adding a 1 like in the example it now should be multiplying
for (var a=0; a < arr[i].length; a*1) {

product =(arr[i][a]); //now the product holds both 1st and second value of the array

//for each number in the sub-arr of array it multiplies the product variable

// Only change code above this line
return product; //this can be used to return the product once it has gone trough the process. 

multiplyAll([[1,2],[3,4],[5,6,7]]); //these are the numbers it needs to multiply 

Your browser information:

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

Challenge: Nesting For Loops

Link to the challenge:

  1. spelling (you wrote length in one place and lenght in the other)
  2. you have infinite loops as you never change a and i
  3. you just set product to last number considered, you don’t multiply anything
1 Like