Codehs | 8.1.5 Manipulating 2d Arrays
8.1.6 – 2D Array Challenges & Algorithms
In the previous lessons, you learned how to create and access elements in 2D arrays (also known as matrices). In 8.1.5, you will go a step further: you will data inside 2D arrays. This is a critical skill for games (grids), data tables, image processing, and more. Codehs 8.1.5 Manipulating 2d Arrays
: The "last element" of any row r is at array[r].length - 1 . Call the method : : The "last element" of any row r is at array[r]
// Task 3: Write a function that swaps the first and last row function swapFirstLastRow(matrix) // Your code here 💡 It is very common to swap the row and column variables
💡 This happens if you try to access array[row] where the row index is equal to or greater than array.length . Always remember that indices go from 0 to length - 1 .
💡 It is very common to swap the row and column variables. Always use the format array[row][column] .