The goal is to render rows with 4 columns cell being the <td>. However the object has 5 data points. How can the object be iterated over so that this will render with the uuid as the value of the buttons rendered in the 4th column? If there is another way to achieve this than below?
const obj = [
{
resident: "Lily",
date: "05/29/2020",
type: "Basketball Court",
status: "approved",
uuid: "ksjdiofjoij3i4jovoii3ni"
},{
resident: "Kyle",
date: "05/30/2020",
type: "Swimming Pool",
status: "denied",
uuid: "wiczoixmcie923fjffj23jij"
}
];
const table = document.querySelector("#table");
Object.keys(obj).forEach(key => {
let row = document.createElement("TR");
Object.entries(obj[key]).forEach(([k, v]) => {
if (k !== "uuid") {
let cell = document.createElement("TD");
if (k === "status") {
cell.innerHTML = `
<button value="` + UUIDHERE + `"class="approve-btn">Approve</button>
<button value="` + UUIDHERE + `"class="deny-btn">Deny</button>`;
} else {
cell.innerHTML = v;
}
row.appendChild(cell);
}
});
table.appendChild(row);
});