Question: JAVASCRIPT Help I have a 2d array that has 9 arrays with 9 elements in each array. [[0,0,0,0,8,0,4,6,1],[0,9,8,0,0,3,0,0,0],[0,0,0,0,0,0,0,0,0],[0,7,0,0,5,4,8,1,0], [2,0,0,0,0,0,0,4,0],[1,0,5,0,0,0,0,0,0],[0,5,0,0,0,7,3,0,2],[0,0,2,0,0,0,0,7,0],[0,0,0,0,6,0,0,0,0]]; I need to get the first

JAVASCRIPT Help

I have a 2d array that has 9 arrays with 9 elements in each array.

[[0,0,0,0,8,0,4,6,1],[0,9,8,0,0,3,0,0,0],[0,0,0,0,0,0,0,0,0],[0,7,0,0,5,4,8,1,0], [2,0,0,0,0,0,0,4,0],[1,0,5,0,0,0,0,0,0],[0,5,0,0,0,7,3,0,2],[0,0,2,0,0,0,0,7,0],[0,0,0,0,6,0,0,0,0]];

I need to get the first three elements out of 3 arrays at a time and create another 2d array with that. This would look like [0,0,0,0,9,8,0,0,0], [0,8,0,0,0,3,0,0,0],[4,6,1,0,0,0,0,0,0] for the first 3. If you think of the initial 2d array like a 9x9 matrix, I need to create 9, 3x3 boxes starting in the top left, going to the right, then the middle left, middle right, bottom, left, bottom right.

I need a function that changes that initial array into the new one as described. In JavaScript.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!