Codehs 8.1.5 Manipulating 2d Arrays <1080p>

var myArray = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; myArray.push([10, 11, 12]); // myArray = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]; Removing a row from a 2D array can be done using the splice() method.

var myArray = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; var value = myArray[1][2]; // value = 6 Modifying an element in a 2D array is similar to accessing an element. You simply assign a new value to the element using its row and column index.

In CodeHS, you can declare and initialize a 2D array using the following syntax: Codehs 8.1.5 Manipulating 2d Arrays

for (var i = 0; i < arrayName.length; i++) { arrayName[i].splice(columnIndex, 1); } For example:

arrayName[rowIndex][columnIndex] = newValue; For example: var myArray = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; myArray

Now that we've covered the basics, let's move on to the fun part – manipulating 2D arrays! In exercise 8.1.5, you'll learn how to perform various operations on 2D arrays. To access an element in a 2D array, you need to specify its row and column index. The syntax is as follows:

var myArray = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; This creates a 3x3 2D array with the specified values. In CodeHS, you can declare and initialize a

for (var i = 0; i < arrayName.length; i++) { arrayName[i].push(newValue); } For example: