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.
Loading...
Related Quiz
- You've encountered a "Callback Hell" in a project you've inherited. What could be a strategic approach to refactor and manage the nested callbacks for better readability and maintainability?
- You're debugging a piece of code and find an unexpected type coercion in a comparison. Which operator is most likely being used that could cause this issue?
- In which scenario might a closure be particularly useful?
- What will be the length of the array after [1, 2, 3].unshift(4, 5);?
- To avoid cross-site scripting (XSS) attacks, instead of innerHTML, use _________.