function transpose(matrix) {
const rows = matrix.length
const col = matrix[0].length
const transposedMatrix = []
for(let j = 0; j < col; j++) {
transposedMatrix[j] = []
for(let i = 0; i < rows; i++) {
transposedMatrix[j][i] = matrix[i][j]
}
}
return transposedMatrix
}
let matrix = [[1,2,3],[4,5,6],[7,8,9]]
console.log(transpose(matrix))
To embed this program on your website, copy the following code and paste it into your website's HTML: