function printUpperTriangular(matrix) {
const rows = matrix.length;
const cols = matrix[0].length;
for (let i = 0; i < rows; i++) {
let s = "";
for (let j = 0; j < cols; j++) {
if (i > j) {
s += "0" + " "
}
else {
s += matrix[i][j] + " ";
}
}
console.log(s);
}
}
const matrix = [ [7, 6, 2],
[9, 4, 3],
[1, 5, 8] ];
printUpperTriangular(matrix);
/*
run:
7 6 2
0 4 3
0 0 8
*/