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 :: change object key name javascript es6 
Javascript :: datatable visable show entries 
Javascript :: javascript json string 
Javascript :: limitar la cantidad de decimales en javascript 
Javascript :: get element property javascript 
Javascript :: js add css class to element 
Javascript :: how select start from id in jquery 
Javascript :: console log returns object object 
Javascript :: odd even condition with ternary operator in javaScript 
Javascript :: give div event listener functional component 
Javascript :: jquery find child of parent sibling 
Javascript :: vim total number of lines 
Javascript :: remove character at index 
Javascript :: iterate array javascript 
Javascript :: jquery trigger link click 
Javascript :: bind and unbind jquery validation 
Javascript :: dropzone add download button 
Javascript :: redirect page using javascript 
Javascript :: Return A Random Number within a range of numbers 
Javascript :: array.foreach 
Javascript :: qrcode.js 
Javascript :: nested destructuring javascript 
Javascript :: Javascript prime number check 
Javascript :: datatable destroy 
Javascript :: getelementbyxpath 
Javascript :: js decode base64 
Javascript :: send data through routes in react 
Javascript :: (node:2736) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead. 
Javascript :: write json file nodejs 
Javascript :: loop an array in javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =