Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

How to rotate a matrix in an array in javascript

function rotate(matrix) {
  return matrix[0].map((col, i) => matrix.map((row) => row[i]))
}

function rotateAntiClockwise(matrix) {
  return matrix[0].map((col, i) => matrix.map((row) => row[i]).reverse())
}
Comment

js rotate matrix

matrix[0].map((val, index) => matrix.map(row => row[index]).reverse())
Comment

PREVIOUS NEXT
Code Example
Javascript :: changetypeprofiles 
Javascript :: react using props and parent state 
Javascript :: aboutreact axios 
Javascript :: _.extend() underscore 
Javascript :: find parent index of nested array object javascript 
Javascript :: removes all item occurrences in array 
Javascript :: converting JSON to jsObject 
Javascript :: how to use graph api with react native 
Javascript :: Using strings, the spread operator creates an array with each char in the string 
Javascript :: JS time set 24H so AM PM tag 
Javascript :: Backbone Models In Collection Is Added Here 
Javascript :: javascript get css property 
Javascript :: codigo para salvar javascript 
Javascript :: convert js to tsx 
Javascript :: Get Error 
Javascript :: erc721 abi json 
Javascript :: delete all document fragments js 
Javascript :: auto refresh vue pwa 
Javascript :: Is It Negative Zero (-0)? js 
Javascript :: puppeteer click is not working 
Javascript :: find the minimum number in an array javascript 
Javascript :: form submit with ajax 
Javascript :: react-bootstrap-sweetalert is not running 
Javascript :: creating a react app from scratch 
Javascript :: angular date passed to donet care is a day less 
Javascript :: sort used in price high and low using angular 
Javascript :: copy array using spread operator 
Javascript :: FILTER METHOD. IMPORTANT 
Javascript :: Examples of correct code for the { "typeof": true } option with global declaration: 
Javascript :: angularjs Manipulate an element that is conditionally rendered 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =