JSFiddle - React, Tailwind, and code Playground

JavaScript

x = [
    [1, 2],
    [5, 6],
    [9, 10]
];
var rows, cols;
rows = x.length;
cols = x[0].length;
if (rows < cols) {
    while (rows != cols) {
        x.push([]);
        for (var j = 0; j < cols; j++) {
            x[rows].push(0);
        }
        rows++;
    }
}

var sum = function (arr) {
    return arr.reduce(function (a, b) {
        return a + b;
    }, 0);
};

// vertical sums
x.map(function (row, i) {
    if (i < cols) {
        console.log(sum(x.map(function (row) {
            return row[i];
        })))
    };
});