Retro_1477,
let matrix = [];
let width = 5;
let height = 3;
let random = (min, max) => Math.round(Math.random() * (max - min) + min);
for (let i = 0; i < height; i++) {
matrix[i] = []
for (let j = 0; j < width; j++) {
matrix[i][j] = random(-99, 99);
}
};
let res = [];
for (let k = 0; k < (width + height) - 1; k++) {
let j = k < height ? 0 : k - height + 1;
let i = k < height ? k : height - 1;
let a = [];
for (; matrix[i] && matrix[i][j] !== void 0; j++, i--) {
a.push(matrix[i][j])
}
a = Math.max(...a)
res.push(a);
};
console.log(res);
console.table(matrix);