function rotateClockwise(matrix) 
  let result = [];
  let rows = matrix.length;
  let cols = matrix[0].length;

for (let j = 0; j < cols; j++) let newRow = []; for (let i = rows - 1; i >= 0; i--) newRow.push(matrix[i][j]); result.push(newRow); return result;


Understanding 8.1.5 isn't just about passing CodeHS—it's a foundational skill for:

To remove a row from a 2D array, you can use the splice() method.

var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
array.splice(1, 1); // remove row at index 1
console.log(array);
// output: [[1, 2, 3], [7, 8, 9]]

To remove a column from a 2D array, you need to iterate through each row and remove the corresponding element.

var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
for (var i = 0; i < array.length; i++) 
  array[i].splice(1, 1); // remove column at index 1
console.log(array);
// output: [[1, 3], [4, 6], [7, 9]]

Modifying an element in a 2D array is similar to accessing an element. You simply assign a new value to the element using its row and column index.

arrayName[rowIndex][columnIndex] = newValue;

For example:

var myArray = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
myArray[1][2] = 10; // myArray = [[1, 2, 3], [4, 5, 10], [7, 8, 9]];

A common mistake is using array.length for the inner loop condition.

PLAYLISTS

Discover the playlists which soundtrack your sport

FOOTBALL

GOLF

TENNIS

BOXING & UFC

FITNESS

CRICKET

RUGBY

DARTS

SPORT TV & RADIO

ESPORTS

US SPORTS

ICE HOCKEY

NEWS

Codehs 8.1.5 Manipulating 2d Arrays Link

function rotateClockwise(matrix) 
  let result = [];
  let rows = matrix.length;
  let cols = matrix[0].length;

for (let j = 0; j < cols; j++) let newRow = []; for (let i = rows - 1; i >= 0; i--) newRow.push(matrix[i][j]); result.push(newRow); return result;


Understanding 8.1.5 isn't just about passing CodeHS—it's a foundational skill for: Codehs 8.1.5 Manipulating 2d Arrays

To remove a row from a 2D array, you can use the splice() method.

var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
array.splice(1, 1); // remove row at index 1
console.log(array);
// output: [[1, 2, 3], [7, 8, 9]]

To remove a column from a 2D array, you need to iterate through each row and remove the corresponding element. function rotateClockwise(matrix) let result = []; let rows

var array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
for (var i = 0; i < array.length; i++) 
  array[i].splice(1, 1); // remove column at index 1
console.log(array);
// output: [[1, 3], [4, 6], [7, 9]]

Modifying an element in a 2D array is similar to accessing an element. You simply assign a new value to the element using its row and column index.

arrayName[rowIndex][columnIndex] = newValue;

For example:

var myArray = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
myArray[1][2] = 10; // myArray = [[1, 2, 3], [4, 5, 10], [7, 8, 9]];

A common mistake is using array.length for the inner loop condition.

SEND YOUR TRACK

Please send us your links and track drops!

Are you an artist looking for playlist support? Or would you like to suggest a song for your team’s playlist? 

Tell us about it! Our playlists are influenced by you. Our playlists are for fans and we want to hear from you. Sport Playlists is a free service.

Submit your track and follow our Sport Playlists Spotify profile and it could be selected to feature on a range of our specially curated sport playlists. 

Oh – and don’t forget to follow the Sport Playlists Spotify profile

CONTACT

Got a question you’d like to ask or feedback you’d like to give?

Feel free to get in touch and one of our team will get back to you.