Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

rotate matrix 90 degrees clockwise javascript

// transpone
const transpose = matrix => {
  for (let row = 0; row < matrix.length; row++) {
    for (let column = 0; column < row; column++) {
      let temp = matrix[row][column]
      matrix[row][column] = matrix[column][row]
      matrix[column][row] = temp
    }
  }
  return matrix;
}
// reverse 
const reverse = matrix =>  matrix.map(row => row.reverse());
// rotate
const rotate = matrix => transpose(reverse(matrix));
Comment

PREVIOUS NEXT
Code Example
Javascript :: axios imgbb 
Javascript :: scan token deploy js 
Javascript :: object destructuring in javascript 
Javascript :: js undici fetch data with agent 
Javascript :: Move capital letters to the beginning 
Javascript :: nodejs stream pipeline 
Javascript :: nextjs check path 404 
Javascript :: get product 
Javascript :: HSETNX in redis 
Javascript :: rpirvate router react 
Javascript :: express-js 
Javascript :: compare text 
Javascript :: arrow functions basic usages in javascript 
Javascript :: select and select based on value in jquery 
Javascript :: inertia.js 
Javascript :: nodejs extract pdf data 
Javascript :: javascript no decimal places 
Javascript :: javascript practice questions 
Javascript :: what is react easy emoji 
Javascript :: javascript output a message into console 
Javascript :: js random seed 
Javascript :: angular architecture patterns 
Javascript :: jquery get parent element 
Javascript :: js array to object 
Javascript :: hide react source 
Javascript :: know when recyclerview is on the last item 
Javascript :: find the length and the last character of string in js 
Javascript :: javascript find ip and information 
Javascript :: javascript async await returns undefined 
Javascript :: variavel javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =