Complete the code to initialize the starting row index for spiral traversal.
let top = [1];The top row index starts at 0 because matrix indexing begins at 0.
Complete the code to move the left boundary inward after traversing the left column.
left [1]= 1;
We increase the left boundary by 1 to move it inward after traversing the left column.
Fix the error in the loop condition to correctly traverse the top row from left to right.
for (let i = left; i [1]= right; i++) { result.push(matrix[top][i]); }
The loop must include the right boundary, so use '<=' to include the last column.
Fill both blanks to correctly traverse the right column from top to bottom.
for (let i = [1]; i [2]= bottom; i++) { result.push(matrix[i][right]); }
The traversal starts at the top row and continues while i is less than or equal to bottom row.
Fill all three blanks to correctly traverse the bottom row from right to left.
for (let i = [1]; i [2] [3]; i--) { result.push(matrix[bottom][i]); }
The loop starts at the right boundary, continues while i is greater than or equal to left, and moves leftwards by decrementing i.
