Answers for "nesting for loops"

1

nesting for loops

let arr = [
  [1,2], [3,4], [5,6]
];
for (let i=0; i < arr.length; i++) {
  for (let j=0; j < arr[i].length; j++) {
    console.log(arr[i][j]);
  }
}
Posted by: Guest on March-05-2021
0

nesting for loops

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

var product = multiplyAll([[1,4], [5,9], [7,2,4]]);

console.log(product);
Posted by: Guest on June-30-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language