Multiplay two matrices

To multiply matrix, take a row from the first matrix and a column from the second matrix, multiply corresponding numbers (first number in the row with the first number in the column, second with second, and so on). Add up all the products. This sum becomes one entry in the new, multiplied matrix. Repeat: Do this for every possible row-column combination to fill the new matrix.

# Python implementation
matrix1 = [
  [ 1, 4, 7 ],
  [ 2, 5, 8 ],
  [ 3, 6, 9 ]
]

matrix2 = [
  [ 1, 4, 7 ],
  [ 2, 5, 8 ],
  [ 3, 6, 9 ]
]

output = []

for i in range(len(matrix1)):
  row = []
  
  output.append(row)
  
  for j in range(len(matrix2[0])):
    total = 0
    
    for k in range(len(matrix1[i])):
      total += matrix1[i][k] * matrix2[k][j]

    row.append(total)

print(output)
// Javascript implementation
const matrix1 = [
  [ 1, 4, 7 ],
  [ 2, 5, 8 ],
  [ 3, 6, 9 ]
];
const matrix2 = [
  [ 1, 4, 7 ],
  [ 2, 5, 8 ],
  [ 3, 6, 9 ]
];

const output = [];

for (let i = 0; i < matrix1.length; i++) {
  const row = [];
  
  output.push(row);
  
  for (let j=0; j < matrix2[0].length; j++) {
    let sum = 0;
    
    for (let k=0; k