JSFiddle - React, Tailwind, and code Playground

HTML

<div id="foo"> </div>

JavaScript

var txt = function(node, text) {
    if (node.innerText !== undefined) {
        node.innerText = text; 
    } else if (node.textContent !== undefined) {
        node.textContent = text;    
    }
}

function createTable(rows, columns) {
    var table = document.createElement("table");
    table.border = '3';
    var tbody = document.createElement("tbody");
    var thead = document.createElement("thead");
    for (var i = 0; i < rows; i++) {
        var tr = document.createElement("tr");
        for (var j = 0; j < columns; j++) {
            var cell;
            if (i === 0) {
                cell = document.createElement("th");
                if (j !== 0) {
                    txt(cell, "x = " + j);
                }
            }
            else {
                if (j == 0) {
                    cell = document.createElement("th");
                    txt(cell, "y = " + i);
                }
                else {
                    cell = document.createElement("td");
                    txt(cell, operation(i, j));
                }
            }
            tr.appendChild(cell);
        }
        if (i === 0) {
            thead.appendChild(tr);    
        } else {
            tbody.appendChild(tr);    
        }
    }
    table.appendChild(thead);
    table.appendChild(tbody);
    
    return table;
}

function operation(i, j) {
    return i * j;    
}

var table = createTable(5,5);
document.getElementById("foo").appendChild(table);