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 = [ [1, 2, 3],
[4, 5, 6],
[7, 8, 9] ];
printUpperTriangular(matrix);
/*
run:
"1 2 3 "
"0 5 6 "
"0 0 9 "
*/