Function to print the elements of the matrix in row - wise manner
function printMatrix ( a ) { for ( let i = 0 ; i < a . length ; i ++ ) { for ( let j = 0 ; j < a [ i ] . length ; j ++ ) { document . write ( a [ i ] [ j ] + " " ) ; } document . write ( " " ) ; } }