Skip to content

Instantly share code, notes, and snippets.

View nishanthreddy114's full-sized avatar

nishanthreddy114

View GitHub Profile
let activities = [
['Work', 9],
['Eat', 1],
['Commute', 2],
['Play Game', 1],
['Sleep', 7]
];
function rotate( parameter ){
@namklabs
namklabs / rotateArrayRight.js
Created April 26, 2016 04:23
rotate a 2D (2 dimensional) array clockwise (right) by 90 degrees in JavaScript
function rotateArrayRight( arr ){
// rotates a 2D array 90 degrees to the right (clockwise)
var newarr = [];
for( var x = 0; x < arr[0].length; x++ ){
newarr[x] = [];
for( var y = arr.length - 1; y >= 0; y-- ){
newarr[x].push( arr[y][x] );
}