Nodejs Array Matrix printMatrix()

Here you can find the source of printMatrix()

Method Source Code

Array.prototype.printMatrix = function() {
  var output = '';
  for (var i = 0; i < this.length; i++) {
    if (i != 0 && i % 5 == 0) {
      output += '\n';
    }//from  w w w .jav a 2  s  .c o  m
    output += (this[i] + ',             ').substring(0, 5);
  }
  console.log(output);
  console.log('------');
}

Related

  1. printMatrix()
    Array.prototype.printMatrix = function() {
      let return_string = '';
      for (row of this) {
        return_string += '[';
        return_string += row.join(', ');
        return_string += "] \n";
      console.log(return_string);