1// Basic Javascript Nested Loop / 2D Array
2
3for (var x = 0; x < 10; x++) {
4 for (var y = 0; y < 10; y++) {
5 console.log("x: " + x + ", y: " + y);
6 }
7}
1 var arr = [[1,2], [3,4], [5,6]];
2 for (var i=0; i < arr.length; i++) {
3 for (var j=0; j < arr[i].length; j++) {
4 console.log(arr[i][j]);
5 }
6}
1//nested for loop
2var arr = [[1,2], [3,4], [5,6]];
3 for (var i = 0; i < arr.length; i++) {
4 for (var j = 0; j < arr[i].length; j++) {
5 console.log(arr[i][j]);
6 }
7}
1for (let exercise = 1; exercise <= 3; exercise++) {
2 console.log(`---------- Starting exercise ${exercise}`)
3
4 for (let rep = 1; rep <= 6; rep++) {
5 console.log(`Exercise ${exercise}: Lifting weight repetitition ${rep}`);
6 }
7}
1
2function multiplyAll(arr) {
3 var product = 1;
4 // Only change code below this line
5 for (var i=0; i<arr.length; i++ ){
6 for (var j=0; j<arr[i].length; j++){
7 product*=arr[j];
8
9 }
10 }
11 // Only change code above this line
12 return product;
13}
14
15// Modify values below to test your code
16multiplyAll([[1,2],[3,4],[5,6,7]]);
17
18