Gistlib Logo

gistlib

find the transpose of the matrix 3 2 1 5 4 3 in javascript

index.tsx
const matrix = [
  [3, 2, 1],
  [5, 4, 3]
];

const transpose = matrix[0].map((_, colIndex) => matrix.map(row => row[colIndex]));

console.log(transpose);
155 chars
9 lines

similar javascript code snippets

how to change the diagonal of a matrix 3x3 with a vector with 3 elements using for loop structurein matlab in javascript
find the lower triangular matrix in javascript
shift matrix in javascript
iterate over matrix in spiral in javascript
display the elements of a matrix a with elements form 1 to 100 that are divisible by 7 using for loop and if function in javascript
matriz de comparação in javascript
how to find inverse of a matrix matlab in javascript
lower triangular matrix in javascript
how to use the transpose function from the underscore library in javascript
how to parse a json string in javascript

related categories

javascript
matrix
transpose

gistlibby LogSnag