OneCompiler

2D Array 90 degrees in an anti-clockwise direction (Java Script )

231

# 2D Array 90 degrees in an anti-clockwise direction (Java Script )*

 let Matrix=[
[1 ,2 ,3, 4],
[5 ,6 ,7, 8],
[1 ,2 ,3, 4],
[5 ,6 ,7, 8],

]

let row=matrix.length;
let col=matrix[0].length;

for(let a=row-1;a>=0;a--){
  let bag="";
  for(let k=0;k<col;k++){
   bag+=matrix[k][a]+" ";
  }
  console.log(bag);
}