JSFiddle - React, Tailwind, and code Playground
JavaScript
function weakPoint(matrix) {
let rowStrength = matrix.map(row => row.reduce((acc, cur) => acc += cur));
console.log(rowStrength);
let colStrength = matrix[0].map((_, i) => matrix.reduce((acc, cur) => acc += cur[i]), matrix[0][0]); // matrix[0][0]? Вместо 7 acc первым значением принимает первый массив
console.log(colStrength);
}
weakPoint([
[7, 2, 7, 2, 8],
[2, 9, 4, 1, 7],
[3, 8, 6, 2, 4],
[2, 5, 2, 9, 1],
[6, 6, 5, 4, 5]
])