function table(arrayOfRecords) {
const keys = Object.keys(arrayOfRecords[0]);
const table = html`<table>`;
const thead = html`<thead>`;
table.appendChild(thead);
thead.appendChild(html`<th>index`);
keys.forEach(key => {
thead.appendChild(html`<th>${key}`);
});
const tbody = html`<tbody>`;
table.appendChild(tbody);
arrayOfRecords.forEach((record, index) => {
const tr = html`<tr>`;
tbody.appendChild(tr);
tr.appendChild(html`<th>${index}`);
keys.forEach(key => {
tr.appendChild(html`<td>${record[key]}`);
});
});
return table;
}