This commit is contained in:
りき萌 2024-04-07 18:11:56 +02:00
parent 13fc5d6a30
commit d8a8ea77fc
5 changed files with 357 additions and 1 deletions

View file

@ -0,0 +1,22 @@
import { addElement } from "treehouse/sandbox.js";
export function showTable(data, schema) {
let table = document.createElement("table");
let thead = table.appendChild(document.createElement("thead"));
for (let column of schema.columns) {
let th = thead.appendChild(document.createElement("th"));
th.textContent = column;
}
let tbody = table.appendChild(document.createElement("tbody"));
for (let row of data) {
let tr = tbody.appendChild(document.createElement("tr"));
for (let column of schema.columns) {
let td = tr.appendChild(document.createElement("td"));
td.textContent = `${row[column]}`;
}
}
addElement(table);
}