Codehs 8.1.5 Manipulating 2d Arrays

To add a new row to a 2D array, you can use the push() method.

for (int r = 0; r < array.length; r++) for (int c = 0; c < array[r].length; c++) // Logic goes here // Access element using: array[r][c]

function rotateClockwise(matrix) let result = []; let rows = matrix.length; let cols = matrix[0].length; Codehs 8.1.5 Manipulating 2d Arrays

In CodeHS 8.1.5, you learned to:

Remove last column:

: fixArray(array, 0, array[0].length - 1, array[0].length);

Modify the array so that cells where (row + col) % 2 == 0 become 1 , and odd sum cells become 0 . To add a new row to a 2D

// Task 2: Write a function that returns a new 2D array with only the even numbers function getEvens(matrix) // Your code here