You're developing a game and you're using a two-dimensional array to represent a grid of game cells. How could you access the third cell in the second row of a grid defined as const grid = [[1,2,3], [4,5,6], [7,8,9]]?

  • grid[2][1]
  • grid[1][2]
  • grid[3][2]
  • grid[2][3]
In JavaScript, two-dimensional arrays are accessed using two pairs of square brackets. To access the third cell in the second row, you should use grid[1][2], where the first index (1) represents the second row, and the second index (2) represents the third cell within that row.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *