Example: Javascript multiply a square matrix
// Multiply a square matrix
const squareMatrix = (a, b) => a.map(x => x.map((_, i) => x.reduce((s, e, j) => s + e * b[j][i], 0)));
console.log(squareMatrix([[1, 2], [3, 2]], [[3, 2], [1, 1]]) );
// Answer: [[5, 4], [11, 8]]
console.log(squareMatrix([[4,5,6], [7,8,9], [10,11,12]], [[3, 2, 1], [1, 1, 9], [12,13,14]]) );
// Answer: [ [ 89, 91, 133 ], [ 137, 139, 205 ], [ 185, 187, 277 ] ]
console.log(squareMatrix([[1,2],[3,4]], [[5,6],[7,8]]) );
// Answer: [ [ 19, 22 ], [ 43, 50 ] ]