Print final matrix
for ( let rows = 0 ; rows < mat . length ; rows ++ ) { for ( let cols = 0 ; cols < mat [ rows ] . length ; cols ++ ) { document . write ( mat [ rows ] [ cols ] + " " ) ; } document . write ( " " ) ; } }